Saturday, June 27, 2009

Compare tables with same data

SQL Query Compare data in two tables having same data

(SELECT * FROM @Table1 EXCEPT SELECT * FROM @Table2) UNION (SELECT * FROM @Table2 EXCEPT SELECT * FROM @Table1)

Will return unque records, if the query returned no records, the data in both table are same.