select * from [yourtable] where field1=field2
select * from [yourtable] where field1<>field2

解决方案 »

  1.   

    if (select CHECKSUM_AGG(checksum(col1)) from tb)
    =
    (select CHECKSUM_AGG(checksum(col2)) from tb)
    print '相同'
    else
    print '不相同'
      

  2.   

    select * from [yourtable] where field1=field2
    select * from [yourtable] where field1<>field2
      

  3.   

    select * from [yourtable] where field1=field2
    select * from [yourtable] where field1<>field2
      

  4.   

    if (select CHECKSUM_AGG(checksum(col1)) from tablename)
    =
    (select CHECKSUM_AGG(checksum(col1)) from othertablename)
    print '相同'
    else
    print '不相同'
      

  5.   

    select a.*,b.* from tb1 a,tb1 b
    where a.col1=b.col1 and a.col2=b.col2
      

  6.   

    相同:
    select * from tb1 a
    where exists(select * from tb2 where col1=a.col1 and col2=a.col2 )
     不同:
    select * from tb1 a
    where not exists(select * from tb2 where col1=a.col1 and col2=a.col2 )
      

  7.   

    顶           qxq321() ( ) 信誉:100 
    应该行。
    楼主应该把问题说明白一点。
      

  8.   

    完全相同:
    select * from tb1 
    where exists(select 1 from tb2 where tb1.col1=col1 and tb1.col2=col2 )完全不同:
    select * from tb1 
    where not exists(select 1 from tb2 where tb1.col1=col1)
    and not exists(select 1 from tb2 where tb1.col2=col2 )