sql server 中如何取得連續(xù)數(shù)字中中斷數(shù)字的最小個

字號:


    如果其中一道題目刪除了,新添加的試題的編號要用中斷編號的最小編號來填充,一個比較好的方法
    表名:tt
    列:id
    用下面的方法就能找出中斷數(shù)字的最小值了
    select min(t.id) as id from (select id=id+1 from tt) t
    where id not in (select id from tt,