SQL Data Compare 8

Using XML to specify command line arguments

You can use an XML file to specify the arguments for the command line interface. You may want to do this because:

  • An XML file is easier to read than a long and complex command line, particularly where complex rules for including and excluding objects are specified.
  • You can easily transform an XML file into other formats using XSLT.
    For example, you could transform your argument file to HTML for presentation on a Web page.
  • Using an XML file overcomes some limitations that can be a problem when you want to specify regular expressions as command line arguments.
    For example, you may want to use the pipe character ( | ) as part of a regular expression, but it causes problems when it is used at the command prompt; if you use an XML file you can use the pipe character with no problems.
  • Most programming languages support XML, through built-in or freely available third-party libraries.
    This makes it easy to generate and process the XML file.

Create the XML file in the following format:

<?xml version="1.0"?> <commandline> <switch_name1/>
<switch_name2>switch_value</switch_name2>
.... </commandline>

For example, for the /Include and /Exclude switches, use the following format:

<include>objecttype:RegularExpression</include>

To execute the command line tools using an XML argument file as input, at the command prompt enter:

sqldatacompare /Argfile:XMLfilename.xml

When using an XML file note that:

  • you cannot specify any other switches on the command line except /verbose or /quiet
  • multiple options should be separated with commas:
<options>n,oc,t</options>

Examples

Below are some examples of XML files that can be used with the SQLDataCompare tool. The command line versions of the examples (using aliases) are also provided for comparison. To migrate changes in the XML examples, use the <synchronize/> element.

To compare the data in all tables in two local databases (Windows authentication):

Using an XML file:

<?xml version="1.0"?> <commandline>
<database1>FirstDatabaseName</database1>
<database2>SecondDatabaseName</database2>
</commandline>

Using the command line:

sqldatacomapre /db1:FirstDatabaseName /db2:SecondDatabaseName

To compare the data in all tables in databases on different hosts:

Using an XML file:

<?xml version="1.0"?> <commandline>
<database1>FirstDatabaseName</database1>
<server1>Hostname1</server1>
<database2>SecondDatabaseName</database2>
<server2>Hostname2</server2>
</commandline>

Using the command line:

sqldatacomapre /db1:FirstDatabaseName /db2:SecondDatabaseName
     /s1:Hostname1 /s2:Hostname2

To compare the data in all tables in two databases using SQL Server authentication:

Using an XML file:

<?xml version="1.0"?> <commandline>
<database1>FirstDatabaseName</database1>
<username1>Username1</username1>
<password1>Password1</password1>
<database2>SecondDatabaseName</database2>
<username2>Username2</username2>
<password2>Password2</password2>
</commandline>

Using the command line:

sqldatacomapre /db1:FirstDatabaseName /u1:Username1
     /p1:Password1 /db2:SecondDatabaseName /u2:Username2
     /p2:Password2

To compare the data only in tables whose name contains the word Product:

Using an XML file:

 

<?xml version="1.0"?> <commandline>
<database1>FirstDatabaseName</database1>
<database2>SecondDatabaseName</database2>
<include>Table:Product</include>
</commandline>

Using the command line:

sqldatacomapre /db1:FirstDatabaseName /db2:SecondDatabaseName
     /include:table:[Product]

To compare the data only in tables whose name contains the word Product, except for the ProductHistory table:

Using an XML file:

<?xml version="1.0"?>
<commandline> <database1>FirstDatabaseName</database1>
<database2>SecondDatabaseName</database2>
<include>Table:Product</include>
<exclude>Table:ProductHistory</exclude>
</commandline>

Using the command line:

sqldatacomapre /db1:FirstDatabaseName /db2:SecondDatabaseName
     /include:table:[Product] /exclude:table:[ProductHistory]

To compare the data in tables using an index as a comparison key:

Using an XML file:

<?xml version="1.0"?> <commandline>
<database1>FirstDatabaseName</database1>
<database2>SecondDatabaseName</database2>
<comparisonkeys>TableName:IndexName</comparisonkeys>
</commandline>

Using the command line:

sqldatacomapre /db1:FirstDatabaseName /db2:SecondDatabaseName
     /comparisonkeys:TableName:IndexName

To compare a backup file with a database:

Using an XML file:

<?xml version="1.0"?> <commandline>
<backup1>D:\MSSQL\BACKUP\BackupOfFirstDatabase.sqb</backup1>
<database2>SecondDatabaseName</database2>
</commandline>

Using the command line:

sqldatacompare /backup1(big grin):\MSSQL\BACKUP\BackupOfFirstDatabase.sqb
     /db2:SecondDatabaseName

To retrieve verbose output of the data differences between two databases:

Using an XML file:

<?xml version="1.0"?> <commandline>
<database1>FirstDatabaseName</database1>
<database2>SecondDatabaseName</database2>
<verbose/>
</commandline>

Using the command line:

sqldatacomapre /db1:FirstDatabaseName /db2:SecondDatabaseName
     /verbose

To migrate data changes from the first database to the second database:

Using an XML file:

<?xml version="1.0"?> <commandline>
<database1>FirstDatabaseName</database1>
<database2>SecondDatabaseName</database2>
<synchronize/>
</commandline>

Using the command line:

sqldatacomapre /db1:FirstDatabaseName /db2:SecondDatabaseName
     /synchronize

Didn't find what you were looking for?