Applies to
ApexSQL Data Diff
Summary
This article explains how to compare and synchronize certain objects by using switches in the CLI for ApexSQL Data Diff.
Description
The Command Prompt has to be run as administrator so that the CLI (Command Line Interface) can be accessed with all privileges to execute any command. When it’s run, enter the exact path to the installation directory of ApexSQL Data Diff.
When in the installation directory, call the console application by entering the filename and extension, ApexSQLDataDiff.com.
To compare certain objects, use the switch /inc, which will include only named objects in the comparison.
Using the /inc switch
The following example shows how to compare only two tables. There are two databases FruitImport2013 and FruitImport2014, and both of them contain four tables: Quarter1, Quarter2, Quarter3, and Quarter4. To compare tables Quarter1 and Quarter3 we’ll use the mentioned switch /inc:8:”^Quarter1$|^Quarter3$”.
The full CLI argument for comparing these two tables is:
C:\Program Files (x86)\ApexSQL\ApexSQLDataDiff2014\ApexSQLDataDiff.com /d1:FruitImport2013 /d2:FruitImport2014 /inc:8:”^Quarter1$|^Quarter3$” /v /of:D:\Test\Compare.sql
Using the /exc switch
If the /exc switch is used on the same example, it will do the opposite of the /inc switch, i.e. it will exclude tables Quarter1 and Quarter3 from the comparison.
|
Quick tip: The /exclude switch is processed after the /include switch (if it is sepcified) |
Explaining expressions in the switch
The number 8 is a bitwise constant that represents tables in this switch. As ApexSQL Data Diff can also compare and synchronize views, so the number that represents bitwise constant for views is 4.
If an incorrect number is used, for example the number 3, it will result with the following error: “Invalid bitwise constant – 3”.
As for “^Quarter1$|^Quarter3$”, “^” is the start of the word position and “$” is the end of the word position, and the pipe character “|” separate the table names. ApexSQL Data Diff will find the whole Quarter1, or Quarter3, name instead of “SomeTextQuarter1SomeText” name.
|
Quick tip: To speed up the process, and use less code in the CLI, create a project file, or an argument file, with wanted comparison and synchronization options |
Last updated
March 6, 2015