November 17, 2008 at 7:40 am
Hi,
I have a question regarding the GUID columns. I do not know much about this GUID data type and wonder whether this could happen or not. I have two tables created for a screen: one is primary table and the secondary table. Both the tables will contain the same fields, but with few extra fields in the secondary table. I have a GUID column as primary key created in both the tables to identify the unique records. In the primary table, I have defined defined the default value (NEWID()) to the GUID column, where as in the secondary table there is no default value set. That means, I need to generate a new GUID everytime a new record is inserted into the secondary table. Now I am in a situation where I need to insert a record (taken from primary table) into a secondary table. I have a question whether there would be any conflict in the GUID column values in the secondary table if I insert a record along with GUID column (taken from primary table) in the second table. I mean, does a GUID value is shared between two or more tables at any time? To be more clear, does the SQL Sever 2005 generates the same GUID value at any time or any point for two or more tables? For example, if we define an IDENTITY column (INTEGER type) in two tables, then there occurs the duplicate IDENTITY values between these two tables, as the IDENTITY values by default start from 1. Is there a similar possibility for GUID columns also? Or the SQL Server 2005 always generates a UNIQUE GUID for every record irrespective of the number of tables (in which GUID column is defined).
Please suggest me your answer to my question. Also if possible, please share the URLs where I can get more detailed information about how the GUIDs are generated by SQL Server 2005. Tons of thanks in advance.
Regards,
Naga
November 17, 2008 at 8:03 am
The answer is no. You have the same chances of generating the same GUID if the column is in the same table or different tables. The table the GUID is being generated for is not part of the routine that generates it's "uniqueness".
Oh, and the changes of generating the same GUID are extremely low and you should be more concerned that your car, your house, and your office will be struck by lightning at the same time three days in a row.
Viewing 2 posts - 1 through 2 (of 2 total)
You must be logged in to reply to this topic. Login to reply
This website stores cookies on your computer.
These cookies are used to improve your website experience and provide more personalized services to you, both on this website and through other media.
To find out more about the cookies we use, see our Privacy Policy