sql 查找自动增长的表中已经删除的记录的id

  create proc a
  as
  declare @i int,@c int
  set @i=1
  set @c=(select MAX(id) from Table_1)
  while (@i<@c+1)
  begin
  select case when  exists ( select id from Table_1 where id=@i) then '[['  else  @i end
  set @i=@i+1
  end
exec a

posted on 2012-05-23 11:42  面包机  阅读(316)  评论(0编辑  收藏  举报

导航