You are here: Re: Adding an auto-increment column to existing table with a particular order « MsSQL Server « IT news, forums, messages
Re: Adding an auto-increment column to existing table with a particular order

Posted by Erland Sommarskog on 10/20/05 01:11

David Portas (REMOVE_BEFORE_REPLYING_dportas@acm.org) writes:
> If you want the cosmetic reassurance of seeing the values in the
> "right" order you can try creating a new table and using INSERT SELECT
> with an ORDER BY clause to populate it. Be aware that that method is
> definitely NOT always guaranteed to generate the values in the correct
> order - so don't count on it. You may also find that the effort of
> creating and populating a new table negates any slight advantage of
> "fixing" the IDENTITY sequence.

In fact, the word I have from Microsoft people is that INSERT SELECT
ORDER BY is guaranteed to produce the expected result.

This however does not apply to SELECT INTO.

I would recommend, nevertheless, to add an OPTION (MAXDOP 1) as an
extra precaution.

It is also worth pointing that the main reason for having IDENTITY
in opposition ro rolling your own, is that IDENTITY scales better in
an environment where there is a heavy insertion rate. When you roll
your own, inserts tend to get serialized.



--
Erland Sommarskog, SQL Server MVP, esquel@sommarskog.se

Books Online for SQL Server SP3 at
http://www.microsoft.com/sql/techinfo/productdoc/2000/books.asp

 

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

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