declare @id int
set @id = ( select max(id) from table1 )
while @id < 20000
begin
set @id = @id + 1
insert into table1 ( id ) select @id
set @id = ( select max(id) from table1 )
end
具他的测试(sql2000): 有 21868条数据,其中1868条重复.
但我在sql2005,一条重复也没有.牛~~
加了事件 跟 锁跟不用说了.安全性更高:
begin tran
declare @id int
set @id = ( select max(id) from table1 )
while @id < 40000
begin
set @id = @id + 1
insert into table1 with (tablock) ( id ) select @id
set @id = ( select max(id) from table1 )
end
commit tran