create table xs(xs varchar(10))insert xs 
select 'a'
union all select 'b'create table kc(kc varchar(10))insert kc
select '1'
union all select '2'
union all select '3'create table sk(xs varchar(10),kc varchar(10))
insert sk
select 'a','1'
union all select 'a','2'
union all select 'b','3'
select xs,kc from xs,kc
select * from sk

解决方案 »

  1.   

    create table t1(a varchar(10),b varchar(10))
    create table t2(a varchar(10),b varchar(10))insert t1
    select 'a','1'
    insert t1
    select 'a','2'
    insert t2
    select 'a','2'select * from t1
    select * from t2如何找出在T1中但不在T2中的记录?
      

  2.   

    --请教了别人
    --http://expert.csdn.net/Expert/topic/3006/3006352.xml?temp=.8323786create table xs(xs varchar(10))insert xs 
    select 'a'
    union all select 'b'create table kc(kc varchar(10))insert kc
    select '1'
    union all select '2'
    union all select '3'create table sk(xs varchar(10),kc varchar(10))
    insert sk
    select 'a','1'
    union all select 'a','2'
    union all select 'b','3'select xs,kc into #t from xs,kc
    select * from #t a
    where not exists (select * from sk where xs=a.xs and kc=a.kc)