Example - selecting single tables for comparison
Published 23 January 2013
This example illustrates how you select a single table for comparison.
In this example, the databases contain the following tables (among others):
- Product
- ProductCategory
- ProductCostHistory
- ProductDealerPriceHistory
- SpecialOfferProduct
You are interested only in the differences between the Product tables in two different versions of your database; you are not interested in any of the other tables or views in the databases.
Using the command line
To specify the table to include, you use the /Include switch:
sqldatacompare /db1:Products1 /db2:Products2 /Include:table:[Product] /verbose
where:
- /db1:Products1
specifies that you want to compare the database Products1 - /db2:Products2
specifies that you want to compare the database Products2 - /Include:table:\[Product\]
specifies that you want to compare only the table that has a name that includes the string [Product] - /verbose
specifies that you want to display detailed information about differences between objects
You must include the brackets ( [ ] ) in the string; if you specify the argument without the brackets, /Include:table:Product, the ProductCategory table is included because it contains the string Product. The full SQL Server table names are qualified by the owner name in SQL Server 2000, and the schema name in SQL Server 2005/2008, and include brackets. For example (in SQL Server 2000):
[dbo].[Product] [dbo].[ProductCategory]
and so on. Therefore, the brackets indicate that you are specifying the full table name. To include the owner (or schema) name in the regular expression, you would need also to escape the dot ( . ):
/Include:table:\[dbo]\ .\[Product\]
The pipe character ( | ) in a regular expression is interpreted as a logical OR. The character must be escaped by the caret character ( ^ ), to prevent the operating system shell from interpreting it as the pipe operator. (Note that if you want to use the caret character itself as part of your regular expression, it must be escaped by a second caret.)
Using XML
You can use XML as follows:
<?xml version="1.0"?> <commandline> <database1>Products1</database1> <database2>Products2</database2> <verbose/> <include>Table:[Product]</include> </commandline>
To execute the comparison using the XML file, enter the following command:
sqldatacomapre /Argfile:xmlfilename.xml
where xmlfilename is the name of the XML file.