Switches used in the command line

This topic gives a 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 Generate scripts of a database.
/scriptsfolder Create a scripts folder of a database.
/quiet (/q) Hide console window in console mode. It should be used after the main operation switch.

Switches details

/execute

Execute a script.

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

/datacompare

Launch data comparison.

Parameter Description
/compfile /compfile:<path>
Load command line settings from comparison .dcomp project file.
/log /log:<filepath>
Generate comparison log file in the specified directory.
/meobjmask /meobjmask:<expression|N>
Exclude 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. Forced disabling of an option from the CLI is necessary if the option is set via UI and then saved in a dcomp file.
/micolmask /micolmask:<expression|N>
Include 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. Forced disabling of an option from the CLI is necessary if the option is set via UI and then saved in a dcomp file.
/report /report:<filepath>
Generate 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. See the documentation to learn more about report formats.
/reportformat /reportformat:<HTML|XLS|CSV>
Specify 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:<yourusername>] [password:<yourpassword>] Connect to a live database by specified parameters. If ‘user’ is not specified, the system’s integrated security is used.
connection:<connection_string> Specify the full connection string with additional parameters.
backup:<filepath> setid:<GUID> Load 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.
/sync /sync[:path]
Launch database synchronization. If an output file path is specified, the program will generate only a synchronization script.
/target Specify target with the following options:
server:<name> database:<db> [user:<yourusername>] [password:<yourpassword>] Connect to a live database by specified parameters. If ‘user’ is not specified, the system’s integrated security is used.
connection:<connection_string> Specify the full connection string with additional parameters.
backup:<filepath> setid:<GUID> Load 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 /{option}:[value]
Specify 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. Forced disabling of an option from the CLI is necessary if the option is set via UI and then saved in a .dcomp file. You can use this switch as many times as many options you want to specify.

/script

Generate scripts of a database.

Parameter Description
/connection /connection:<connection_string>
Specify the connection string.
/database Specify a database to script or override the database specified in a template or in a connection string.
/outputfile Specify a file name for storing the database script or override the file name specified in template.
/password /password:<pw>
Specify the server password or override the password specified in the connection string.
/projectfile /projectfile:<path>
Specify script template to use. Some template options can be overridden by switches.
For more information about how to generate a projectfile, see How to generate SQL Server database scripts.

/scriptsfolder

Create a scripts folder of a database.

Parameter Description
/connection /connection:<connection_string>
Specify the connection string.
/database Specify a database to script or override the database specified in a template or in a connection string.
/decrypt /decrypt:[value]
Define if source objects should be decrypted during describing.
/includedata /includedata:[value]
Define whether to include data. To turn on the option, specify: Yes, Y, On, True, T. To turn off the option, specify: No, N, Off, False, F.
/password /password:<pw>
Specify the server password or override the password specified in the connection string.
/path /path:<folder_path>
Define a scripts folder 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 <required path> (for example, “C:\Program Files\Devart\Compare Bundle for SQL Server\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\Compare Bundle for SQL Server\dbForge Data Compare for SQL Server\datacompare.com" /datacompare /source backup:"D:\backup_file.bak" /target server:mssql2014 database:db_name user:yourusername password:"yourpassword" /CheckIdentical:Yes /sync:"D:\sync_script.sql"( /report:"D:\report_file.html")

Note

The path to the executable file will differ depending on which tools suite you have installed Data Compare with - Compare Bundle or SQL Tools. Make sure that you have specified a correct path. If you have installed Data Compare as part of SQL Tools, change the path accordingly:

C:\Program Files\Devart\dbForge SQL Tools Professional\dbForge Data Compare for SQL Server\datacompare.com

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=yourusername;Pooling=False;Transaction Scope Local=True" /target connection:"Data Source=ServerB;Enlist=False;Initial Catalog=AdventureWorks2019_Test;Integrated Security=False;Password=yourpassword;User ID=yourusername;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=yourusername;Pooling=False;Transaction Scope Local=True" /target connection:"Data Source=ServerB;Enlist=False;Initial Catalog=AdventureWorks2019_Test;Integrated Security=False;Password=yourpassword;User ID=yourusername;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

Want to Find out More?

Overview

Overview

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

All features

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

Request a demo

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