Switches used in the command line

This topic gives detailed description of command line switches and examples of their usage.

You can select the required options while setting the comparison in the Data Comparison wizard and generate a file with command line arguments by clicking Save settings to a file.

Command line usage

datacompare [/argfile:path] [/operation_switch] [/switch1[:value | [parameter1:value parameter2:value ..]] /switch2 ..]

The first argument for datacompare is usually an operation switch that corresponds to the operation that you want to perform with the application.

Available command-line switches

Switch Usage
/argfile /argfile:<path>
  Path to command-line arguments file. Options specified in the command line have higher priority than the options which were given in the file.
/activate Activate a product using activation key.
/deactivate Deactivate a product.
/execute Execute a script.
/datacompare Launch data comparison.
/script Script a database.
/scriptsfolder Create a scripts folder of the target schema.
/quiet (/q) Hide console window in console mode. It should be used after the main operation switch.

Switches details

/execute

Execute script.

Parameter Description
connection Is used to specify the connection string: /connection:<connection_string>
database Is used to specify a database to script or override the database specified in a template or in a connection string.
encoding Is used to specify the encoding which should be applied to open and execute the script: /encoding:<codepage|encoding name>
inputfile Is used to specify an SQL or ZIP file with a script to execute.
password Is used to specify the server password or override the password specified in the connection string: /password:<pw>
zippassword Is used to enter a password for protected archive with script: /zippassword:<zip password>

/datacompare

Launch data comparison.

Parameter Description
compfile Usage: /compfile:<path>. Loads command line settings from comparison .dcomp project file.
log Usage: /log:<filepath>. Generates comparison log file in the specified directory.
meobjmask Usage: /meobjmask:<expression/N>. Excludes objects from the comparison if they match the given expression. To exclude objects from the comparison, specify mask expression. To turn off the option, specify: No, N, Off, False, F.
micolmask Usage: /micolmask:<expression/N>. Includes objects to comparison if they match the given expression. To include objects to comparison, specify mask expression. To turn off the option, specify: No, N, Off, False, F.
report Usage: /report:<filepath>. Generates data comparison report file. If the output file name has .html, .xls or .xml extension, it’s not necessary to specify the file format - it will be chosen depending on the extension. Please see the documentation to learn more about report formats.
reportformat Usage: /reportformat:<HTML|XLS|CSV>. Specifies the format of the file comparison report: HTML - a simple HTML file; XLS - a simple Microsoft Excel file; CSV - a simple CSV file. If the format was not specified, it is determined by the extension of the report file.
source Specifies source with the following options:
  server:<name> database:<db> [user:<name>] [password:<pw>] Connects to a live database by specified parameters. If ‘user’ is not specified, the system’s integrated security is used.
  connection:<connection_string> Allows specifying the full connection string with additional parameters.
  backup:<filepath> setid:<GUID> Loads database backup from one or several files. To specify multiple backup files, you should specify “backup:<path>” parameter as many times as many files you have. The parameter “setid” specifies unique backup set.
  scriptsfolder:<folderpath> Loads database objects from the specified scripts folder.
sync Usage: /sync[:path] Launches database synchronization. If an output file path is specified, the program will generate only a synchronization script.
target Specifies target with the following options:
  server:<name> database:<db> [user:<name>] [password:<pw>] Connects to a live database by specified parameters. If ‘user’ is not specified, the system’s integrated security is used.
  connection:<connection_string> Allows specifying the full connection string with additional parameters.
  backup:<filepath> setid:<GUID> Loads database backup from one or several files. To specify multiple backup files, you should specify “backup:<path>” parameter as many times as many files you have. The parameter “setid” specifies unique backup set.
  scriptsfolder:<folderpath> Load database objects from the specified scripts folder.
options Usage: /{option}:[value]. Specifies the value for comparison or synchronization option. To turn on the option, specify: Yes, Y, On, True, T. To turn off the option, specify: No, N, Off, False, F. You can use this switch as many times as many options you want to specify.

/script

Script database.

Parameter Description
connection Is used to specify the connection string: /connection:<connection_string>
database Is used to specify a database to script or override the database specified in a template or in a connection string.
outputfile Is used to specify a file name for storing the database script or override the file name specified in template.
password Is used to specify the server password or override the password specified in the connection string: /password:<pw>
projectfile Is used to specify script template to use. Some template options can be overridden by switches: /projectfile:<path>

/scriptsfolder

Make a scripts folder of a target database.

Parameter Description
connection Is used to specify the connection string: /connection:<connection_string>
database Is used to specify a database to script or override the database specified in a template or in a connection string.
decrypt Is used to define if source objects should be decrypted during describing: /decrypt:[value]
includedata Is used to define whether to include data: /includedata:[value]
  * To turn on the option, specify: Yes, Y, On, True, T.
  * To turn off the option, specify: No, N, Off, False, F.
password Is used to specify the server password or override the password specified in the connection string: /password:<pw>
path Is used to define a scripts folder path: /path:

Usage Examples

To practice comparison and synchronization through the command line, try to generate a synchronization script for a database backup and a live database. To do this, you should first change the default path in the command line by typing cd (for example, "C:\Program Files\Devart\dbForge Data Compare for SQL Server\datacompare.com") and pressing Enter. After the default directory has changed, type the following arguments into the Command Prompt:

"C:\Program Files\Devart\dbForge Data Compare for SQL Server\datacompare.com" /datacompare /source backup:"D:\backup_file.bak" /target server:mssql2014 database:db_name user:user_name password:"password" /CheckIdentical:Yes /sync:"D:\sync_script.sql"( /report:"D:\report_file.html")

1. Compare data using settings from a file saved earlier:

/datacompare /compfile:"D:\workDir\DC1vsDC2.dcomp"

2. Compare and synchronize data using a connection string. To write a log to the specified file, use: /log:”D:\sync.log”.

/datacompare /source connection:"Data Source=serverA;Enlist=False;Initial Catalog=AdventureWorks2019;Integrated Security=False;User ID=sa;Pooling=False;Transaction Scope Local=True" /target connection:"Data Source=ServerB;Enlist=False;Initial Catalog=AdventureWorks2019_Test;Integrated Security=False;Password=su;User ID=su;Pooling=False;Transaction Scope Local=True" /sync /log:"D:\sync.log"

3. To compare data of the specified databases and save the synchronization script to the file, use: /sync:”D:\compare_result.sql”

/datacompare /source connection:"Data Source=serverA;Enlist=False;Initial Catalog=AdventureWorks2019;Integrated Security=False;User ID=sa;Pooling=False;Transaction Scope Local=True" /target connection:"Data Source=ServerB;Enlist=False;Initial Catalog=AdventureWorks2019_Test;Integrated Security=False;Password=su;User ID=su;Pooling=False;Transaction Scope Local=True" /sync:"D:\compare_result.sql"

4. Compare and synchronize data using settings from the file, do not generate comments in the synchronization script, turn off dml triggers during synchronization; generate a report to the specified file in the HTML format:

/datacompare /compfile:"DC1vsDC2.dcomp" /nocomments:yes /nodml:yes /report:"report.txt" /reportformat:HTML /sync

5. Compare and synchronize data using settings from a file. Synchronize Lob columns using files:

/datacompare /compfile:"D:\workDir\DC1vsDC2.dcomp" /fspath:"\\SqlHost\Temp" /sync

6. Compare data and generate data report using settings from a file. Comparison and data writing settings of the different objects will be included into the report.

/datacompare /compfile:"DC1vsDC2.dcomp" /report:"report.html" /incdata:Yes /incsettings:Yes