Re: uniqueidentifier

Tech Tip: Click here to run a free scan for Windows Errors and optimize PC performance

From: Dan Guzman (danguzman_at_nospam-earthlink.net)
Date: 03/12/04


Date: Fri, 12 Mar 2004 07:59:19 -0600


> Can I be assured that the value will always be unique? (Within reason,
I'm sure statistically there must be some point that I run out of values)

Yes, it is highly unlikely that a dup GUID value will be generated since the
generation algorithm includes the computer's mac address and time component.

> Thinking space and efficiency - If I choose to go with a GUID as my PK is
it best to keep it as a datatype uniqueidentifier for make it a varchar(32)
inserting replace(newid(),'-','')?

Uniqueidentifier is internally stored as a 16 byte binary value so
converting it to varchar(32) will at least double your space requirements.

-- 
Hope this helps.
Dan Guzman
SQL Server MVP
"Hutch" <anonymous@discussions.microsoft.com> wrote in message
news:243FA2FE-1BA3-4B9B-9E17-13A161E8323B@microsoft.com...
> Thinking about creating a table with a PK of uniqueidentifier default
NEWID().  Can I be assured that the value will always be unique?  (Within
reason, I'm sure statistically there must be some point that I run out of
values)
> Thinking space and efficiency - If I choose to go with a GUID as my PK is
it best to keep it as a datatype uniqueidentifier for make it a varchar(32)
inserting replace(newid(),'-','')?
>
> Thanks
> -Hutch
>