思路而已,见笑
先把1到n的数转为数组,然后用sql语句:where 编号 not in (数组)
这样应该是可以的吧

解决方案 »

  1.   

    select * from tab where rec_no no in (1.2.3.4.5.6)
      

  2.   

    CREATE TABLE #(ID INT NOT NULL IDENTITY(1,1),A VARCHAR(10))INSERT INTO @(A)
    SELECT TOP 5000 '1' FROM TABLESELECT ID
    FROM # A  LEFT JOIN TBALE B
    ON  A.ID=B.ID 
    WHERE B.ID IS NULL
      

  3.   

    select * from tab where rec_no no in (1,2,3,4,5,6)
      

  4.   

    select top 5000 identity(int,1,1) id into #a from sysobjects a,sysobjects bselect * from #a where id not in (select id from 你的表) and id<(select max(id) 你的表)
      

  5.   

    假设字段是a
     
          select isnull(min(a+1),1) from  (select a from 原来表  union select 0  from 原来表) t where not exists (select 1 from 原来表 where t.a+1 =原来表.a)
      

  6.   

    “缺少的一個數”比较好办:select 编号+1 as 缺少的编号 from 表 as a where not exists(select * from 表 where
      编号=a.编号+1)
    否则:
    select 编号,(select min(编号) from 表 where 编号>a.编号) from 表 as a 
      where not exists(select * from 表 where 编号=a.编号+1)
      

  7.   

    加上:and a.编号<(select max(编号) from 表)