第1个回答 2011-05-20
declare @a table(id int)
insert into @a
select 1
union select 2
union select 3
union select 4
declare @b table(id int)
insert into @b
select 1
union select 2
union select 6
union select 5
select * from @a a inner join @b b on a.id=b.id
delete from @a where id not in (select id from @b)
delete from @b where id not in (select id from @a)
select * from @a
select * from @b