Automate data comparison and synchronization from the command line

The /datacompare command lets you run data comparison from the command line.

Note

The command-line interface is available in the Professional and Enterprise editions of dbForge Studio for SQL Server.

Syntax

dbforgesql.com /datacompare [/option_name1[:value | [parameter1:value parameter2:value ..]] /option_name2 ..]

Get command-line help

To view the list of arguments available for the /datacompare command, run the following command:

dbforgesql.com /datacompare /?

Command details

  • To run dbForge Studio CLI commands, open Command Prompt and navigate to the folder that contains dbforgesql.com. The default path to this executable depends on where dbForge Studio for SQL Server is installed. If you installed dbForge Studio:

    As a standalone tool

    "C:\Program Files\Devart\dbForge Studio for SQL Server"
    

    As part of the dbForge Edge bundle

    "C:\Program Files\Devart\dbForge Edge\dbForge Studio for SQL Server"
    
  • To enter all arguments, use one of the following options:

    • Type all the arguments directly in the Command Prompt.
    dbforgesql.com /datacompare /source connection:"Data Source=<server_name>;Initial Catalog=<catalog>;Integrated Security=False;User ID=yourUsername;Password=yourPassword" /target connection:"Data Source=<server_name>;Initial Catalog=<catalog>;Integrated Security=False;User ID=yourUsername;Password=yourPassword"
    
    • Specify a path to a previously generated .txt file with required command-line arguments by using the /argfile command.
    /argfile:"D:\file_name.txt"
    
    • Specify a path to the data comparison project (.dcomp) with the source and target connection strings and comparison settings by using the /compfile command.
    /compfile:"C:\MyComparison.dcomp"
    
  • To synchronize the data and generate a synchronization script, specify the file location and name in the /sync command.

/sync:"D:\sync_script.sql" 
  • To generate and save a log file, specify the file name and location in the /log command.
/log:"D:\LogFile.log" 
  • To generate and save a data comparison report file, specify the file name and location in the /report command.
/report:"D:\MyReport.html" 
  • To specify the report format, use the /reportformat command.
/reportformat:HTML

Create a .txt file with command-line arguments

You can generate a .txt file with command-line arguments in the New Data Comparison wizard or create a .bat file containing commands to be executed by the Command Prompt sequentially from the command-line wizard.

Examples

Compare a backup and a live database

This command compares data in a backup file with a live target database, then generates a synchronization script and a report.

dbforgesql.com /datacompare /source backup:"D:\backup_file.bak" /target server:<target_server> database:<target_database> user:<user_name> password:<pw> /CheckIdentical:Yes /sync:"D:\sync_script.sql" /report:"D:\report_file.html"

Compare and synchronize two databases

This command compares two live SQL Server databases, synchronizes them, and logs all activity to a file.

dbforgesql.com /datacompare /source connection:"Connect Timeout=120;Data Source=<source_server>;Initial Catalog=<source_database>;Integrated Security=False;User ID=<source_username>;Password=<source_pw>;Pooling=False" /target connection:"Connect Timeout=120;Data Source=<target_server>;Initial Catalog=<target_database>;Integrated Security=False;User ID=<target_username>;Password=<target_pw>;Pooling=False" /sync /log:"D:\sync.log"

Compare the data of two databases and generate a synchronization script

This command compares the data of the specified databases and saves a synchronization script to a .sql file.

dbforgesql.com /datacompare /source connection:"Data Source=<source_server>;Initial Catalog=<source_database>;Integrated Security=True" /target connection:"Data Source=<target_server>;Initial Catalog=<target_database>;Integrated Security=True" /sync:"D:\sync_script.sql"

Compare and synchronize data using a .dcomp file

  • This command runs the data comparison by using a predefined project file (.dcomp), generates an HTML report, suppresses SQL comments and all DML statements, and performs the data synchronization without data modifications.
dbforgesql.com /datacompare /compfile:"D:\file.dcomp" /nocomments:yes /nodml:yes /report:"D:\report.html" /reportformat:HTML /sync
  • This command compares data by using a predefined project file (.dcomp), uses a shared network path for temporary files, and directly synchronizes the target database with the source.
dbforgesql.com /datacompare /compfile:"D:\workDir\DC1vsDC2.dcomp" /fspath:"\\SqlHost\Temp" /sync
  • This command compares data and generates a data report by using a predefined project file (.dcomp), and includes comparison and data-writing settings for different objects into the generated report.
dbforgesql.com /datacompare /compfile:"D:\Compare\DC1vsDC2.dcomp" /report:"D:\Reports\CompReportDC1vsDC2.html" /reportformat:html /includeobjects:All /incdata:Yes /incs:Yes