T-SQL表匹配 [英] T-SQL Table Match

查看:85
本文介绍了T-SQL表匹配的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有2个表,我需要比较表1中的数据是否具有表中的对应数据2(而不是反过来)

I have 2 tables and I need to compare whether data existing in Table 1 has correspoinding data in Table 2 ( and not the other way round)

匹配将基于字段ID。并且需要比较所有表格列值  (从表1到表2)

Match will be on basis of field ID . and all table column values need to compared  ( from Table 1  to Table 2)

以下是数据的样子和预期结果表

Here is how data looks like and expected result table

提前致谢。

Thanks in advance.

推荐答案

要比较数据,最好使用工具,例如
RedGate
用于比较。

快速数据比较的另一种方法(如果比较整行)是使用EXCEPT关键字。

Another way for quick data comparison (if comparing the entire row) is using EXCEPT keyword.

SELECT * FROM Table1

SELECT * FROM Table1

EXCEPT

表2中的SELECT *;

SELECT * from Table2;

您将在Table1中记录Table2中不存在的内容(它将是整行匹配)。希望这有帮助!

You will records in Table1 that does not exist in Table2 (it will be entire row match). Hope this helps!


这篇关于T-SQL表匹配的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆