create function F_inc()
returns int
as
begin
declare @n int
select @n=isnull(min(id),0)+1 from n1 A where (A.id+1) not in (select id from n1 B)
return @n
end
drop table n1
go
create table n1(id int default dbo.F_inc(),num int)
insert into n1(num) select 1
union select 2
union select 3
union select 4
union select 5
union select 6
union select 7
delete from n1 where num=2 or num=6
insert into n1(num) select 11
insert into n1(num) select 100
go
select * from n1
楼主这么块就揭帖了...
我写了一个函数,你可以试试.实现类似自增函数的效果.