How to compare and synchronize schemas from the command line

You can automate schema comparison and synchronization using the command line.

  1. Click Start, and type cmd in the Run line. Press ENTER. The Command Prompt opens.

  2. Type a path to the dbforgesql.com file, located in dbForge Studio for SQL Server installation folder on your PC, and press SPACEBAR.

  3. Type all the arguments (actions you want to run) in the Command Prompt. You can do this in three ways:

  • Type all the arguments directly in the Command Prompt, for example:
/schemacompare /source connection:"Data Source=source_name;Integrated Security=False;User ID=yourusername;
Password=yourpassword;database=database_name" /target connection:"Data Source=tartget_name;
Integrated Security=False;User ID=yourusername;Password=yourpassword;database=database_name"
  • Specify a path to a previously saved comparison document to use the connection settings along with the comparison settings specified in the document.
/schemacompare /compfile:"D:\file_name.scomp"
  • Type the path to a previously generated file with required command line arguments (see below how to prepare the file), for example:
/argfile:"D:\file_name.txt"
  • Type additional parameters that are not specified in the file into the Command Prompt, for example:
C:\Program Files\Devart\dbForge Studio for SQL Server>dbforgesql.com /schemacompare /argfile:file_name.txt /sync

Tip: To see a quick help on the arguments available in the command line, type the following:

dbforgesql.com /?

Press ENTER to run the process.

Prepare a file with command line arguments

  1. Define what action you want to run, for example:
/schemacompare
  1. Define Source and Target connection strings:
/schemacompare /source connection:"Data Source=DBMSSQL\MSSQL2012;Integrated Security=False;User ID=yourusername;
database=AdventureWorks" /target connection:"Data Source=DBMSSQL\MSSQL2012;Integrated Security=False;
User ID=yourusername;database=AdventureWorks"

You can also use the schema comparison document that already contains Source and Target connection strings.

/schemacompare /compfile:"C:\MyComparison.scomp"
  1. To generate and save a log file, specify the file name and location. For example:
/log:"C:\Log.log"
  1. To generate and save a comparison report file, specify the file name and location. For example:
/report:"C:\Report.html"
  1. To synchronize the schemas, i.e., update the Target schema, type the following:
/sync
  1. To generate and save a synchronization script, specify the file location and name. For example:
/sync:"C:\sync_script_name.sql"

Helpful materials

Master the Art of Database Comparisons with PowerShell and dbForge Studio for SQL Server

Discover the process of automating database comparisons using PowerShell in conjunction with dbForge Studio for SQL Server.

Want to Find out More?

Overview

Overview

Take a quick tour to learn all about the key benefits delivered by dbForge Studio for SQL Server.
All Features

All features

Get acquainted with the rich features and capabilities of the Studio in less than 5 minutes.
Request a demo

Request a demo

If you consider employing the Studio for your business, request a demo to see it in action.
Ready to start using dbForge Studio for SQL Server?