SQL Compare - 10.0
Example: selecting tables with unrelated names
This example illustrates how you select a number of individual tables for comparison when their names are not related in any way.
In this example, the databases contain the following tables:
- Product
- Supplier
- ProductCategory
- SpecialOffer
- Customer
- Order
- Invoice
You are interested only in the schema differences between the Product, Customer, Order, and Invoice tables in two different versions of your database, Customers1 and Customers2; you are not interested in any of the other tables, or any other objects in the databases.
Using the command line
To specify the list of tables to include, you use the /include switch. You could use an include switch for each table that you want to compare. However, this could get unwieldy if you have a long list of tables. Instead, you can use the pipe character ( | ) to separate the table names:
sqlcompare /db1:Customers1 /db2:Customers2 /Include:table
/Include:table:\[Product\]^|Customer^|Order^|Invoice
where:
/db1:Customers1 specifies that you want to compare the database Customers1
/db2:Customers2 specifies that you want to compare the database Customers2
/Include:table specifies that you want to compare only tables; you do not want to compare other objects such as views, stored procedures, and so on. If you omit this argument, SQL Compare compares all tables that match the second /Include switch and all other objects in the databases.
To specify more than one object type for inclusion, use multiple /Include switches. For example, to include only tables and views, enter:
/Include:table /Include:view/Include:table:\[Product\]^|Customer^|Order^|Invoice
specifies that you want to compare only the tables that have a name that includes the strings [Product], or Customer, or Order, or Invoice
Note that you use .NET standard regular expressions to define the /Include and /Exclude arguments. Therefore, you must escape the square brackets ( [ ] ) with the backslash character ( \ ). Regular expression syntax is beyond the scope of this online help; refer to your Microsoft .NET framework documentation for more information.
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>Customers1</database1>
<database2>Customers2</database2>
<sync/>
<include>Table</include>
<include>Table:\[Product\]|Customer|Order|Invoice</include>
</commandline>
Note that the pipe character ( | ) (and other operating system operators) do not have to be escaped by the caret character ( ^ ) when they are specified in the XML file.
To execute the comparison using the XML file, enter the following command:
sqlcompare /Argfile:XMLFileName.xml
where XMLFileName is the name of the XML file.
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