SQL Data Compare 8

What is a comparison key?

When comparing data sources, SQL Data Compare looks for a matching primary key or other unique identifier in each data source to use as the comparison key. This enables matching rows to be identified, and their differences to be compared.

For example, the databases WidgetSales and WidgetDeploy each contain the table [dbo].[WidgetPrices]:

Since rows can be inserted and deleted, we can not be certain that the third row in WidgetSales is the same as the third row in WidgetDeploy. Simply comparing rows in the order in which they appear in the table can result in a meaningless comparison. Similarly, rows can not be matched based on their Price values - more than one widget can have the same price.

In [dbo].[WidgetPrices], RecordID is a primary key. No two widgets will have the same RecordID, and the rows are uniquely identified. Two matching RecordID values in WidgetSales and WidgetDeploy therefore represent the same piece of real world data.

Where there is no matching primary key, or other unique identifier you must set an appropriate comparison key when selecting tables and views for comparison.

For example, if you know that two widgets with the same name are never added to the database on the same day, you can select the two columns WidgetName and DateValidFrom to form the comparison key. The rows in the tables can now be matched.


Didn't find what you were looking for?