Reputation: 1
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 should be sent to another table with the particular data. Can any one help me in solving out this? Thanks in advance.
Regards, Gokul.
Upvotes: 0
Views: 1373
Reputation: 70369
try
INSERT INTO MyTableDiff
SELECT * FROM
(
(SELECT * FROM MyTable1 EXCEPT SELECT * FROM MyTable2)
UNION
(SELECT * FROM MyTable2 EXCEPT SELECT * FROM MyTable1)
);
Upvotes: 2