SQL Data Compare - 10.0
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:D:\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
See also |
Was this article helpful?
SQL Data Compare
- Logging and log files
- Internal Connection Fatal Error in versions 4 and 5
- NULL textptr passed to UPDATETEXT function when running synchronization
- How much free hard disk space is required?
- Comparing the data of two tables in the same database
- Suggestions to combat comparison and synchronization performance issues
- SQL comparison and synchronization automation capabilities
- SqlNullValueException occurring in synchronization wizard
- SQL Data Compare command-line XML argument file examples
- Using Windows authentication logons between domains
- Using a filter on a column on related (joined) tables
- Determining minimum database permissions for SQL Data Compare
- Tables with compound keys may not be mapped automatically
- Best practices for synchronizing data
- Cleaning up a SQL script after SQL Compare or SQL Data Compare
- Troubleshooting System.OutOfMemoryException during comparison
- Exception thrown by db reader 1
- Reseed applying "incorrect" identity values
- Running migration scripts using SqlCmd.exe
- This SQL Server has been optimized for x concurrent queries.
- SQL Data Compare showing differences in 2 identical databases
- How to force SQL Compare and SQL Data Compare to use an Encrypted Connection
- Improving the performance of SQL Data Compare
- Logging and log files
- Case-sensitive comparisons
- Tables or views that could not be compared
all SQL products
- Compatibility of Red Gate tools in 64-bit environments
- Application has encountered an error and needs to close
- Error message after installing SQL Toolbelt - The description for Event ID ( 1 ) in Source ( nview_info ) cannot be found.
- Changing the temporary directory used by the installer
- Toolbelt Installer "hanging" while "scanning volumes"
- Login failing with "trusted SQL Server connection" error when using RunAs
all products
- Some Red Gate products identified as containing a trojan by Anti-Virus software
- Activation may fail with Unknown Error -1
- Product uses web help although a CHM file is available locally
- Argument exception resulting from missing environment variable
- Check for updates may fail when used through proxies
- 'Unidentified Publisher' error when repairing or uninstalling
- Licensing activates product as standard edition
- Moving Red Gate software products to another machine
- Red Gate tools log locations
- The application UI opening slowly when there is no internet access
SQL Data Compare
- Activating your products
- Activating your products
- Getting help offline
- Getting better performance out of SQL Data Compare
- Release notes - version 10.xx
- SQL Data Compare release notes - version 7.xx
- SQL Data Compare release notes - version 8xx
- SQL Data Compare release notes - version 9.xx
all SQL products
all products
- Red Gate product acknowledgements
- Activating your products
- Activating your products
- Red Gate bundle history
- Check for updates
- Troubleshooting Check for Updates errors
- Current versions
- Deactivating your products
- Installing Red Gate products from the .msi file
- Requesting additional activations
- Serial numbers for bundles
- Reactivating using a different serial number
- Extending your trial
- Finding your serial numbers
- Moving a serial number from one computer to another
- No response received for manual activation
- Licensing and activation resources
- Licensing and activation resources
- Troubleshooting licensing and activation errors
- Licensing and activation FAQs
- Red Gate tools log file locations
- Download old versions of products
- Download product prerequisites & utilities
- Support & upgrades
- Upgrading your software
- Upgrading FAQs

Using SQL Data Compare