You are here: Re: Sequence generator « MsSQL Server « IT news, forums, messages
Re: Sequence generator

Posted by newtophp2000 on 06/20/06 11:41

Alexander Kuznetsov wrote:
> > 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';

This looks interesting. A suggestion that was very similar to this one
came up a while ago in our project. As I remember, the developers did
not like the idea as it introduced more work for them to manage.

Thanks for the tip!

 

Navigation:

[Reply to this message]


Удаленная работа для программистов  •  Как заработать на Google AdSense  •  England, UK  •  статьи на английском  •  PHP MySQL CMS Apache Oscommerce  •  Online Business Knowledge Base  •  DVD MP3 AVI MP4 players codecs conversion help
Home  •  Search  •  Site Map  •  Set as Homepage  •  Add to Favourites

Copyright © 2005-2006 Powered by Custom PHP Programming

Сайт изготовлен в Студии Валентина Петручека
изготовление и поддержка веб-сайтов, разработка программного обеспечения, поисковая оптимизация