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:filepath] [/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:<filepath>
Specifies the path to the command-line arguments file. Options specified in the command line have higher priority than the options that were given in the argfile.
/activate Activates a product using activation key.
/deactivate Deactivates a product.
/execute Executes a script.
/datacompare Launches data comparison.
/script Generates scripts of a database.
/scriptsfolder Creates a scripts folder of a database.
/quiet (/q) Hides 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>
Specifies the connection string.
/password /password:<yourpassword>
Specifies the server password or override the password specified in the connection string.
/database Specifies a database to script or override the database specified in a template or in a connection string.
/encoding /encoding:<codepage|encoding name>
Specifies the encoding which should be applied to open and execute the script.
/inputfile Specifies an SQL or ZIP file with a script to execute.
/zippassword /zippassword:<zip password>
Enters a password for protected archive with script.

/datacompare

Launch data comparison.

Parameter Description
/compfile /compfile:<filepath>
Loads command line settings from comparison .dcomp project file.
/log /log:<filepath>
Generates comparison log file in the specified directory.
/meobjmask /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. 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>
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. 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>
Generates a data comparison report file. If the output file name has a .html, .xls or .xml extension, it’s not necessary to specify the file format - it will be chosen depending on the extension.
For more information, refer to Options used in the command line.
/reportformat /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:<yourusername>] [password:<yourpassword>] Connects to a live database by specified parameters. If ‘user’ is not specified, the system’s integrated security is used.
connection:<connection_string> Specifies 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 /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:<yourusername>] [password:<yourpassword>] Connects to a live database by specified parameters. If ‘user’ is not specified, the system’s integrated security is used.
connection:<connection_string> Specifies 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.
/options /{option}:[value]
Specifies the value for comparison, synchronization, or comparison report 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. For more information, refer to Options used in the command line.

/script

Generate scripts of a database.

Parameter Description
/connection /connection:<connection_string>
Specifies the connection string.
/password /password:<pw>
Specifies the server password or override the password specified in the connection string.
/database Specifies a database to script or override the database specified in a template or in a connection string.
/outputfile Specifies a file name for storing the database script or override the file name specified in template.
/projectfile /projectfile:<path>
Specifies 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>
Specifies the connection string.
/password /password:<pw>
Specifies the server password or override the password specified in the connection string.
/database Specifies a database to script or override the database specified in a template or in a connection string.
/decrypt /decrypt:[value]
Defines if source objects should be decrypted during describing.
/includedata /includedata:[value]
Defines 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.
/path /path:<folder_path>
Defines 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

Note

To build the command-line syntax, it’s better to use the Command-line Wizard.

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?