How to compare two tables for differences?
How to compare two tables for differences? Execute the following Microsoft SQL Server 2008 T-SQL scripts in Query Editor to demonstrate the comparison of two tables for differences in rows and/or columns (cells). ------------ -- SQL SERVER COMPARE 2 TABLES FOR ROW & COLUMN DIFFERENCES ------------ -- TEMPLATE - SQL Server T-SQL compare two tables SELECT Label = 'Found IN Table1, NOT IN Table2' ,* FROM ( SELECT * FROM Table1 EXCEPT SELECT * FROM Table2 ) x UNION ALL SELECT Label = 'Found IN Table2, NOT IN Table1' ,* FROM ( SELECT * FROM Table2 EXCEPT SELECT * FROM Table1 ) y GO ------------ -- SQL Server T-SQL compare Product tables for 2005 & 2008 SELECT Label = 'Found IN AW