SQL 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:
sqlcompare /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 SQL Compare. 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.
Note that in all these examples, you can use a scripts folder or snapshot in place of a database. Use <scripts1> and <scripts 2> in the XML file for a scripts folder, and <snapshot1> and <snapshot2> for a snapshot. In the command line, replace /db with /scr for a scripts folder or /snp for a snapshot.
To compare all objects 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:
SQLCompare /db1:FirstDatabaseName /db2:SecondDatabaseName
To compare all objects 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:
sqlcompare /db1:FirstDatabaseName /s1:Hostname1
/db2:SecondDatabaseName /s2:Hostname2
To compare all objects 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:
sqlcompare /db1:FirstDatabaseName /u1:Username1 /p1:Password1
/db2:SecondDatabaseName /u2:Username2 /p2:Password2
To retrieve verbose output of the 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:
sqlcompare /db1:FirstDatabaseName /db2:SecondDatabaseName
/Verbose
To migrate schema 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:
sqlcompare /db1:FirstDatabaseName /db2:SecondDatabaseName
/sync
To compare only tables containing the word "Product":
Using an XML file:
<?xml version="1.0"?>
<commandline>
<database1>FirstDatabaseName</database1>
<database2>SecondDatabaseName</database2>
<include>Table</include>
<include>Table:Product</include>
</commandline>
Using the command line:
sqlcompare /db1:FirstDatabaseName /db2:SecondDatabaseName
/Include:table /Include:table:\[Product\]
To compare only tables containing 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</include>
<include>Table:Product</include>
<exclude>Table:ProductHistory</exclude>
</commandline>
Using the command line:
sqlcompare /db1:FirstDatabaseName
/db2:SecondDatabaseName
/Include:table /Include:table:\[Product\]
/Exclude:table:\[ProductHistory\]
Scripts folder database information file
When you create a scripts folder, an XML file containing some basic details about the structure of the database is created. The file is called RedGateDatabaseInfo.xml and is stored in the main scripts folder at the top level.
The file contains the following information, with the defaults as shown:
<?xml version="1.0" encoding="utf-16">
<DatabaseInformation>
<DefaultCollation>Latin1_General_CI_AS</DefaultCollation>
<DefaultSchema>dbo</DefaultSchema>
<DefaultUser>dbo</DefaultUser>
<DefaultFilegroup>PRIMARY</DefaultFilegroup>
<DatabaseVersion>9</DatabaseVersion>
</DatabaseInformation>
If you have your own set of SQL creation scripts that you want to use in SQL Compare, you can specify the settings for your schema by editing this file. If the file does not exist when you run the comparison, SQL Compare creates it, using the default values.
See also |
Was this article helpful?
SQL Compare
- Logging and log files
- Stored Procedures and Functions created with wrong name
- Synchronization scripts may be in incorrect version of SQL syntax
- Extended properties not permitted error (version 5.2)
- CLR Procedures' permissions are not recreated (version 5)
- Support for 'returns NULL on NULL Input' in CLR functions (version 5)
- Project files (scp files) suddenly appear on desktop (version 5)
- Stored procedures using full-text queries fail to synchronize
- When does the synchronization process rebuild tables?
- Unable to begin a distributed transaction error synchronizing databases
- User or role already exists in the current database error
- Clarification on the "Ignore Triggers" option in the SQL Compare command-line version
- Common table expressions returned by User Defined Functions may fail
- Can't compare encrypted text in SQL Server 2005, 2008
- Exception when connecting to SQL Server (Version 6)
- SQL comparison and synchronization automation capabilities
- Error logging in SQL Compare 6.2
- Using Team Foundation Server source control system
- Creating a SQL 2000 compatible database from a SQL 2005 database using SQL Compare
- Support for numbered stored procedures
- SQL Compare 7 Object-level restore
- Index was outside the bounds of the array error when registering databases X64
- HTML reports are generated for identical comparisons
- Comparison may seem slower than necessary
- DEFAULT_SCHEMA clause cannot be used with a Windows group
- SQL Compare may drop and create CLR assemblies
- SDK activation prompt may appear when starting a new SQL Compare project
- Column does not allow nulls. INSERT fails
- This SQL Server has been optimized for x concurrent queries.
- SQL Compare comparison differences
- Using SQL Server Management Studio Express as a query editor
- How to force SQL Compare and SQL Data Compare to use an Encrypted Connection
- Invalid SQL when synchronizing an index to a scripts folder when data compression is specified
- Tips
- Changes to distribution of command line
- Common error messages
- Copying the structure of a database
- Permissions required to use SQL Compare
- Rollback on script failure or cancellation
- Errors in scripts folders
- Logging and log files
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 Compare
- Activating your products
- Activating your products
- Getting help offline
- Release notes - version 9.5 EAP
- Introducing SQL Compare 8: FAQs for SQL Compare 7 users
- Release notes - version 10.xx
- SQL 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 Compare