寻找在SQL Server中设置"差异"的简单/可扩展方式,请参阅下文.
![]()
如果你无法从图片中看出我正在寻找那些不在交叉路口的东西.
我已经看到了一种方法:
select * from (
(select 'test1' as a, 1 as b)
union all
(select 'test2' as a , 2 as b union all select 'test1' as a , 1 as b )
)un group by a,b having count(1)=1
Run Code Online (Sandbox Code Playgroud)
但是我担心如果我使用两个大集合会发生什么(我不会从select''常量语句中查询,我的查询将从实际表中提取.)
编辑:
可能解决方案
drop table #temp_a;
drop table #temp_b;
go
select * into #temp_a from (
select 1 as num, 'String' as two, 'int'as three, 'purple' as four union all
select 2 as num, 'dog' as two, 'int'as …Run Code Online (Sandbox Code Playgroud)