开发者

Comparing two tables in SQL Server 2005 using stored procedure

开发者 https://www.devze.com 2023-03-31 23:03 出处:网络
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 pa

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)
);
0

精彩评论

暂无评论...
验证码 换一张
取 消