如何只返回不匹配的列 [英] How to return only mismatched columns
本文介绍了如何只返回不匹配的列的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
i有两个相同的表叫做master和new。当我更新master表时,它应该与新表进行比较,只返回不匹配的列。
我尝试了什么:
i尝试过使用但是返回全部cloumns
解决方案
这是解决问题的两种方法。
1.您可以使用EXCEPT或INTERSECT设置运算符。例如
SELECT id,name FROM master.dbo.test
EXCEPT - < span class =code-comment>或INTERSECT
SELECT id,name FROM test.dbo.testings
2.信息架构的使用
选择 *
FROM questions_table
WHERE questioncolumn IN
(
选择 column_name
来自 information_schema.columns 其中 table_name = ' dynamic_table'
);
Hi,
i have two identical tables called master and new.when i update master table its should compare with new table and return only mismatched columns.
What I have tried:
i have tried by using except but its returning all cloumns解决方案Here is two way to resolve your problem .
1. You can use the EXCEPT or INTERSECT set operators for this. for example
SELECT id, name FROM master.dbo.test EXCEPT -- or INTERSECT SELECT id, name FROM test.dbo.testings
2. Use of Information Schema
select * FROM questions_table WHERE questioncolumn IN ( select column_name from information_schema.columns where table_name='dynamic_table' );
这篇关于如何只返回不匹配的列的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文