select count(table1.*)as _count distinct from table1 where table1.f1 = table2.f2
select Count(*) as count1 from table1if (_count = count1) then   ...

解决方案 »

  1.   

    如果2表的f1或f2有主键.declare @c1 int, @c2 intselect @c1=count(*) from table1 inner join table2 on table1.f1=table2.f1 and table1.f2=table2.f2select @c2=count(*) from table1 
    if @c1 = @c2
       ...
      

  2.   

    用EXCEPT啦。
    Select f1,f2 from  table2
    except
    select f1 f2 from table1
      

  3.   

    参见:
    http://go.163.com/~zcn/db2y040.htm#Header_45我想这方面,SQL Server 和 DB2应该是相同的吧,呵呵
      

  4.   

    不行了,越来越感觉sqlserver不行了,连完整的集合操作都没有
    oracle里用minus不就搞定了.
    select * from a minus select * from b
    或者用多字段IN操作也可以搞定.
    select count(*) from table1 where (f1,f2) in (select * from table2)
      

  5.   

    'in' should be 'not in'