--如果表中没有text、ntext、image、cursor ,可以考虑使用checksum(),如:
--A中有,而B中没有的数据:select *
from A
where checksum(*) not in (select checksum(*) from B)
--A、B中都有的数据select *
from A
where checksum(*) in (select checksum(*) from B)

解决方案 »

  1.   

    checksum 嗯,用哈希值来过滤.
    不过还是不够简约. 很奇怪MS为什么不实现intersect运算和minus运算.在字面上就让人很容易理解.checksum........
      

  2.   

    checksum 的算法,数据不同的两行,确定生成的哈希码一定会不一样吗?
    有没有机率会出现不同两行结果哈希码一样的情况?
    在海量数据中,担心出现此问题.
      

  3.   

    --如果查但个字段,用假设表A和表B都只有两个字段id,name
    如何用一句SQL返回表A中存在的id,name结果集而在表B中不存在的id,name结果集select A.* from A left join B on A.id=B.id and A.name=B.name where B.id is nullselect * from A where not exists(select top 1 * from B where A.ID=B.ID)这两个都可以.
    --如果查所有字段,前提:表中不能有text、ntext、image、cursor 数据类型的字段。用CheckSum()最简单:select * from A where checksum(*) not in (select checksum(*) from B)