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.
datacompare.com [/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.
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. |
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. |
Launch data comparison.
Parameter | Description |
---|---|
/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. |
/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. |
/compfile | /compfile:<filepath> Loads command line settings from comparison .dcomp project file. |
/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. |
/sync | /sync[:path] Launches database synchronization. If an output file path is specified, the program will generate only a synchronization script. |
/report | /report:<filepath> Generates a data comparison report file. If the output file name has .html, .xls or .csv extension, there’s no need to specify the file format as it will be automatically determined based on the extension. For more information, refer to Options used in the command line. |
/reportformat | /reportformat:<HTML|XLS|CSV> Specifies the format of the comparison report file. If the format is not specified, it is determined by the extension of the report file. |
/includeobjects | /includeobjects:<All|Filtered|Diff|SelectForSync Specifies objects for the report: * All - all objects; * Filtered - filtered objects; * Diff - objects with differences; * SelectForSync - objects selected for synchronization. The option refers specifically to the report generation in the HTML/XLS/XML formats and does not work separately from the /report:<filepath> key. |
/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. |
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. |
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. |
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.