Visual Studio Data Comparison (MS SQL) of table with no primary key, unique key, or index

If you have stumbled across this post you are looking to compare two Microsoft SQL Server tables using Visual Studio 2005 or 2010. You have run into issues with the table you need to compare not appearing in the comparison wizard.

If you have a read of this link http://msdn.microsoft.com/en-us/library/aa833428.aspx it explains tables and views must meet two criteria to appear in the listing. First, the schema’s of the objects must match between the source and target databases. Second, only tables and views that have a primary key, a unique key, or an index appear in the list. If no tables or views meet both criteria, the list will be empty.

One solution is to temporarily add the primary keys on the tables needed then remove them once the comparison has been done. Seems obvious, but under pressure you might not think of it straight away.

Advertisements