--追加到临时表#D中
select *
into #D
from (
select * 
from A
where not exists(select * from B 
where isnull(A.id,0)=isnull(B.ID,0) 
and isnull(A.name,'')=isnull(B.name,'') 
and isnull(A.Note,'')=isnull(B.Note,''))union
select * 
from B
where not exists(select * from A
where isnull(A.id,0)=isnull(B.ID,0) 
and isnull(A.name,'')=isnull(B.name,'') 
and isnull(A.Note,'')=isnull(B.Note,''))) C--查询数据
select * from #D--删除临时表
drop table #D

解决方案 »

  1.   

    以上假设三个字段分别是:ID, Name, Note,其中任意一个字段不同都显示出来
      

  2.   

    select * into D from A,B where A.ID=B.ID and A.name<>B.name
      

  3.   

    其实可以分2步来做。1先建1张表 select * from a,b where a.a1<>b.b1 and a.a2<>b.b2.....
     2,再来建1新表,专门用来分类 用一循环对上表中的数据进行比较,将不同的数据写入新表中即可
    这些都用用程序来控制,如果是光写语句会比较困难点