也就是找出id1,2,3,4,5在表a中不存在的!比如1,2在表a中不存在,那么就显示出来!!

解决方案 »

  1.   

    select top 5 identity(int,1,1) as id into #tbl from sysobjects,syscolumns
    select id from #tbl where id not in (select id from a)
      

  2.   

    zhaoanle(zhao) ( ) 信誉:100  2006-03-03 15:54:00  得分: 0  
     
     
       select top 5 identity(int,1,1) as id into #tbl from sysobjects,syscolumns
    select id from #tbl where id not in (select id from a)
      
     
    ==========================
    必须用到零时表吗
      

  3.   

    select * from (select '1' as id union all
    select '2' as id union all
    select '3' as id union all
    select '4' as id union all
    select '5' as id ) a where not exists(select 1 from tb where id=a.id)
      

  4.   

    wgsasd311(自强不息) ( ) 信誉:100 
    ============
    我的ID数量不是固定的,有可能很多呀
      

  5.   

    select top 5 identity(int,1,1) as id into #t from sysobjects,syscolumns
    select t.id from #t t where not exists(select 1 from a where id=t.id)
      

  6.   

    --我只想出这个方法了
    select top 5 identity(int,1,1) as id into #tbl from sysobjects,syscolumns
    select id from #tbl where id not in (select id from a)--如果ID多的话就加大临时表的行数
    select top 10000 identity(int,1,1) as id into #tbl from sysobjects,syscolumns
    select id from #tbl where id not in (select id from a)
      

  7.   

    wgsasd311(自强不息) ( ) 信誉:100 
    很好用,谢谢