SQL Compare 6   

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:

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 you use an XML file to supply the arguments, you cannot specify any other switches on the command line except /verbose or /quiet.

Examples

Below are some examples of XML files that can be used with the SQLCompare 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.

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 /db2:SecondDatabaseName /s1:Hostname1           
           /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 for which the name contains 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 for which the 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</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 export the structure of a database to a scripts folder, an XML file containing some basic details about the database is generated automatically by SQL Compare. The file is called SqlCompareDatabaseInfo.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.

 

 


© Red Gate Software Ltd 2007. All Rights Reserved.