Comparing two tables in SQL Server 2005 using stored procedure
I want to compare the two tables in a same database using stored procedure in SQL Server 2005. If the rows are different, the different row sho开发者_如何学JAVAuld be sent to another table with the particular data. Can any one help me in solving out this? Thanks in advance.
Regards, Gokul.
try
INSERT INTO MyTableDiff
SELECT * FROM
(
(SELECT * FROM MyTable1 EXCEPT SELECT * FROM MyTable2)
UNION
(SELECT * FROM MyTable2 EXCEPT SELECT * FROM MyTable1)
);
精彩评论