资源 地址 
Microsoft 产品支持服务 Web 站点 http://support.microsoft.com/directory 
Microsoft Usenet news://msnews.microsoft.com/ 
Microsoft Windows® 硬件兼容性列表 http://www.microsoft.com/hcl 
MSDN® http://msdn.microsoft.com 
Meta Data Services(即以前的 Microsoft 知识库) http://msdn.microsoft.com 
SQL Server 专业协会 http://www.sqlpass.org/ 
Microsoft SQL Server 开发人员中心 http://msdn.microsoft.com 
SQL Server 杂志 http://www.sqlmag.com/ 
Microsoft SQL Server 技术支持 http://support.microsoft.com/support/sql 
TechNet 站点 http://www.Microsoft.com/technet 
Microsoft 辅助工具 Web 站点 http://www.microsoft.com/enable 
Microsoft SQL Server Web 站点 http://www.microsoft.com/sql 
Microsoft SQL Server Web 站点上的 English Query 页 http://www.microsoft.com/sql 
Microsoft SQL Server Web 站点上的 Analysis Services 页 http://www.microsoft.com/sql 
XML 开发人员中心 http://www.msdn.microsoft.com/xml/default.asp 

解决方案 »

  1.   


    关系运算:并运算
    select c1,c2 from t1
    union all
    select c1,c2 from t2差:
    c1-c2:select * from t1 where not exists(select 1 from t2 where t1.c1=t2.c1 and t1.c2=t2.c2)c2-c1:select * from t2 where not exists(select 1 from t1 where t1.c1=t2.c1 and t1.c2=t2.c2)交:
    select * from t1 where exists(select 1 from t2 where t1.c1=t2.c1 and t1.c2=t2.c2)
    除:
    create table #1(A char(1),B char(1),C char(1),D char(1))
    insert #1 values('a','b','c','d')
    insert #1 values('a','b','e','f')
    insert #1 values('b','c','e','f')
    insert #1 values('e','d','c','d')
    insert #1 values('e','d','e','f')
    insert #1 values('a','b','d','e')create table #2 (A char(1),B char(1))
    insert #2 values('c','d')
    insert #2 values('e','f')select a,b from #1 bb where exists(select 1 from (select distinct #1.a,#1.b,#2.a c,#2.b d from #1,#2) aa where aa.a=bb.a and aa.b=bb.b and aa.c=bb.c and aa.d=bb.d) group by a,b having count(*)>1用left join来着差运算create  table #a(a int,b int)
    create  table #b(a int,b int)
    insert #a values(1,1)
    insert #a values(2,2)
    insert #b values(1,1)
    insert #b values(3,3)#a-#b
    select a.*
    from #a a left join #b b on a.a=b.a and a.b=b.b
    where b.a is null#b-#a
    select b.*
    from #b b left join #a a on a.a=b.a and a.b=b.b
    where a.a is nullor:
    select b.*
    from #a a right  join #b b on a.a=b.a and a.b=b.b
    where a.a is null
      

  2.   

    关系运算:并运算
    select c1,c2 from t1
    union all
    select c1,c2 from t2差:
    c1-c2:select * from t1 where not exists(select 1 from t2 where t1.c1=t2.c1 and t1.c2=t2.c2)c2-c1:select * from t2 where not exists(select 1 from t1 where t1.c1=t2.c1 and t1.c2=t2.c2)交:
    select * from t1 where exists(select 1 from t2 where t1.c1=t2.c1 and t1.c2=t2.c2)
    除:
    create table #1(A char(1),B char(1),C char(1),D char(1))
    insert #1 values('a','b','c','d')
    insert #1 values('a','b','e','f')
    insert #1 values('b','c','e','f')
    insert #1 values('e','d','c','d')
    insert #1 values('e','d','e','f')
    insert #1 values('a','b','d','e')create table #2 (A char(1),B char(1))
    insert #2 values('c','d')
    insert #2 values('e','f')select a,b from #1 bb where exists(select 1 from (select distinct #1.a,#1.b,#2.a c,#2.b d from #1,#2) aa where aa.a=bb.a and aa.b=bb.b and aa.c=bb.c and aa.d=bb.d) group by a,b having count(*)>1用left join来着差运算create  table #a(a int,b int)
    create  table #b(a int,b int)
    insert #a values(1,1)
    insert #a values(2,2)
    insert #b values(1,1)
    insert #b values(3,3)#a-#b
    select a.*
    from #a a left join #b b on a.a=b.a and a.b=b.b
    where b.a is null#b-#a
    select b.*
    from #b b left join #a a on a.a=b.a and a.b=b.b
    where a.a is nullor:
    select b.*
    from #a a right  join #b b on a.a=b.a and a.b=b.b
    where a.a is null