I have a user_info table in five different locations. Now I need to integrate all the rows into a central user_info table. To do this I need a unique id for each row in source tables. Because when all the rows come into the central table, then each user must have a unique ID.
Now my questions are:
-
if I use
uniqueidentifierNEWID()for each source table then is it will be unique for globally & life time or have any chance to be duplicate? -
How does SQL Server create the
NEWID()? I need to know the key generation structure.
Yes, there is no chance of a duplicate between machines.
NEWID()is based on a combination of a pseudo random number (from the clock) and the MAC address of the primary NIC.However, inserting random numbers like this as the clustered key on a table is terrible for performance. You should consider either
NEWSEQUENTIALID()or a COMB-type function for generating GUIDs that still offer the collision-avoidance benefits ofNEWID()while still maintaining acceptableINSERTperformance.