在表A中存储的是  规格个数10
在表B中存储的是  规格排序
                    1
                 2
                 7
去掉已有的排序  想得到没有的排序
 3
 4
 5
 6
 8
 9
 10sql语句该怎样写呢??

解决方案 »

  1.   

    declare @i intselect @i=max(规格个数) from aset rowcount @i
    select id=identity(int,1,1),1 into # from syscolumns
    select id from # where id not in(select 规格排序 from b)
    set rowcount 0
      

  2.   

    select colid from syscolumns where id=object_id('syscolumns') and colid<=10 and colid not in (select 规格排序 from B表)  order by 1
      

  3.   

    select max(colid) from syscolumns where  id=object_id('syscolumns')
    用这个只有32列,要是超过32列该咋办啊???