Please start any new threads on our new site at https://forums.sqlteam.com. We've got lots of great SQL Server experts to answer whatever question you can come up with.

 All Forums
 SQL Server 2000 Forums
 Transact-SQL (2000)
 uniqueidentifier

Author  Topic 

objkiran
Starting Member

11 Posts

Posted - 2005-04-05 : 10:51:06
Hello all,
1. using is using uniqueidentifier datatype a good practice?
2. What are the chances of a duplicate record in uniqueidentifer in more than 2 serves?

AndyB13
Aged Yak Warrior

583 Posts

Posted - 2005-04-05 : 11:02:06
Look it up in BOL, it lists all the pros and cons

1. No unless you need global uniqueness, but you can still have the same "value" in 1 or more tables
2. 0.0000000000000000000000000000000000%

Andy

Beauty is in the eyes of the beerholder
Go to Top of Page

objkiran
Starting Member

11 Posts

Posted - 2005-04-05 : 14:54:33
Little confused with your answer, if same value is in one or more table then how is it chances for duplucate is 0.0000000000000000000000000000000000% ?
Go to Top of Page

rockmoose
SQL Natt Alfen

3279 Posts

Posted - 2005-04-05 : 16:18:20
Good answer Andy.
"value" - You have to have something with business meaning that uniquely identifies a record.
Just having a GUID as the only PK/UNIQUE CONSTRAINT is very bad practice.

GUID is just a 16-byte value that can serve as surrogate key,
so most of the time it's just a waste of space,
unless You need globally unique surrogates.

rockmoose
Go to Top of Page

Michael Valentine Jones
Yak DBA Kernel (pronounced Colonel)

7020 Posts

Posted - 2005-04-05 : 18:37:04
There is also an extremely small, but real chance that uniqueidentifer will not be unique, even in the same table, since uniqueidentifer has "only" about 3.4E+38 possible unique values.






CODO ERGO SUM
Go to Top of Page

AndyB13
Aged Yak Warrior

583 Posts

Posted - 2005-04-06 : 01:52:04
quote:
Originally posted by objkiran

Little confused with your answer, if same value is in one or more table then how is it chances for duplucate is 0.0000000000000000000000000000000000% ?


You asked if it could be duplicated in 2 servers, the answer to which is NO. But it can exist in the same table if a PK or a UNIQUE CONSTRAINT are not defined.
As I said look it up in BOL. Also see rockmoose's reply

Michael - are you sure about this?

Quote from BOL
The main advantage of the uniqueidentifier data type is that the values generated by the Transact-SQL NEWID function or the application GUID functions are guaranteed to be unique throughout the world.

Pretty bold statement if it isnt true

Andy

Beauty is in the eyes of the beerholder
Go to Top of Page
   

- Advertisement -