CREATE TABLE #bbb ( id INT, name VARCHAR ( 20 ) )
insert into #bbb values(1,'aaaaaaaaaaaaa')
insert into #bbb values(1,'bbbbbbbbbbbbb')
insert into #bbb values(1,'ccccccccccccc')
insert into #bbb values(1,'ddddddddddddd')
SELECT * FROM #bbb
CREATE TABLE #ccc ( id INT, name VARCHAR ( 20 ) )
insert into #ccc values(1,'aaaaaaaaaaaaa')
insert into #ccc values(1,'bbbbbbbbbbbbb')
insert into #ccc values(1,'eeeeeeeeeeeee')
insert into #ccc values(1,'fffffffffffff')
select * from #ccc
-- 并集
select * from #bbb union select * from #ccc
select * from #ccc union select * from #bbb
-- 可重复并集
select * from #bbb union all select * from #ccc
select * from #ccc union all select * from #bbb
-- 差集
select * from #bbb except select * from #ccc
select * from #ccc except select * from #bbb
-- 交集
select * from #bbb intersect select * from #ccc
select * from #ccc intersect select * from #bbb
drop table #bbb
drop table #ccc