如何在sqlserver中比较不同表的两行 [英] How to compare two rows of different tables in sqlserver
本文介绍了如何在sqlserver中比较不同表的两行的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
大家好
任何人都可以告诉我如何比较两个不同表(相同列)的两行,我想在它们之间进行更改吗?
谢谢
Hi All
can any body tell me how can I compare two rows of two differnt tables(same columns), I want to get the chages between them
Thanks
推荐答案
如果您使用的是SQL 2005+,请使用以下命令,这将为您提供所有不同的行:
If you are using SQL 2005+ then use the following which will give you all the rows which are different:
SELECT * FROM (SELECT * FROM table1
EXCEPT
SELECT * FROM table2) a
UNION ALL
SELECT * FROM (SELECT * FROM table2
EXCEPT
SELECT * FROM table1) b
这篇关于如何在sqlserver中比较不同表的两行的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文