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 schemacompare.com file, located in dbForge Schema Compare 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:
/schemacompare /source connection:"Data Source="source_name";Integrated Security=False;User ID=user_name;
Password=password;database=database_name" /target connection:"Data Source="target_name";
Integrated Security=False;User ID=user_name;Password=password;database=database_name"
/schemacompare /compfile:"D:\file_name.scomp"
/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 Schema Compare for SQL Server\schemacompare.com" /argfile:file_name.txt /schemacompare /sync
Tip
To see a quick help on the arguments available in the command line, type the following:
/schemacompare.com /?
Press ENTER to run the process.
1. Define what action you want to run, for example:
/schemacompare
2. Define Source and Target connection strings:
/schemacompare /source connection:"Data Source="DBMSSQL\MSSQL2012";Integrated Security=False;User ID=sa;
database=AdventureWorks" /target connection:"Data Source="DBMSSQL\MSSQL2012";Integrated Security=False;
User ID=sa;database=AdventureWorks"
You can also use the schema comparison document that already contains Source and Target connection strings.
/schemacompare /compfile:"C:\MyComparison.scomp"
3. To generate and save a log file, specify the file name and location. For example:
/log:"C:\Log.log"
4. To generate and save a comparison report file, specify the file name and location. For example:
/report:"C:\Report.html"
5. To synchronize the schemas, i.e., update the Target schema, type the following:
/sync
6. To generate and save a synchronization script, specify the file location and name. For example:
/sync:"C:\sync_script_name.sql"
See also: How to automatically track database schema changes with PowerShell scripts.