select id=isnull(a.id,b.id)
,说明=case when a.id is null then '仅在表2中' else '仅在表1中' end
from 表1 a full join 表2 b on a.id=b.id
where a.id is null or b.id is null
,说明=case when a.id is null then '仅在表2中' else '仅在表1中' end
from 表1 a full join 表2 b on a.id=b.id
where a.id is null or b.id is null
select id from a inner join b on a.id<>b.id