|
Posted by Alexander Kuznetsov on 06/19/06 22:03
> declare @next int
> begin transaction
> update my_sequence set seq = seq + 1 where name = 'abc';
> select @next = seq from my_sequence where name = 'abc';
> commit transaction
>
If you can consume numbers in batches, do it, as it is dramatically
more efficient. For instance, if you know up front that you need 100
numbers, do this:
update my_sequence set seq = seq + 100 where name = 'abc';
select @next = seq - 99 from my_sequence where name = 'abc';
Navigation:
[Reply to this message]
|