What's a comparison key?
Published 05 June 2013
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. :
Since rows can be inserted and deleted, we can't 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 might result in a meaningless comparison. Similarly, rows can't be matched based on their Price values, as more than one widget can have the same price.
In [. , 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's 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.