[thelist] SQL Server auto-increment

Scott Dexter sgd at ti3.com
Tue Jan 23 14:46:31 CST 2001


> you can have an initial seed value and an increment (which 
> default to 1,1),
> and i'm pretty sure (would need to look this up, or wait a 
> few secs for
> scott or somebody else to jump in) they can also be random

<tip type="SQL Server 7">
want a random unique id field?

add a column, name it your usual unique id field name (we use guid), with a
datatype of "uniqueidentifier." Make it non-Nullable, and give it a default
of (newid()).

The T-SQL function newid() automagically generates a random 32 byte GUID
that is guaranteed unique (according to the docs) across the planet, for our
lifetime.
</tip>

sgd




More information about the thelist mailing list