可以按照娃娃说的那样,建一个号码库,插入值1-1000,然后写一个存储过程来实现你的业务,
里面包含一个事务:
declare
@id int
begin transaction
--step 1
select @id= min(id) from id_table
--step 2
insert into yourtable (id) where id = @id
if @@error <> 0 then
begin
rollback transaction
return
end
--step 3
delete from id_table where id = @id
if @@error <> 0 then
begin
rollback transaction
return
end
commit transaction