SQL Clone
SQLServerCentral is supported by Redgate
 
Log in  ::  Register  ::  Not logged in
 
 
 


How to generate UniqueIdentifiers and insert in a column


How to generate UniqueIdentifiers and insert in a column

Author
Message
Mac1986
Mac1986
Mr or Mrs. 500
Mr or Mrs. 500 (581 reputation)Mr or Mrs. 500 (581 reputation)Mr or Mrs. 500 (581 reputation)Mr or Mrs. 500 (581 reputation)Mr or Mrs. 500 (581 reputation)Mr or Mrs. 500 (581 reputation)Mr or Mrs. 500 (581 reputation)Mr or Mrs. 500 (581 reputation)

Group: General Forum Members
Points: 581 Visits: 791
Hi All,
I have a table in which one of the column is UniqueIdentifier. I have NULLS from records 1 through 91 and then after I have records populated in the table. I need to fill up the NULLS with UniqueIdentifier. Can you please help me.

My only concern is if I update the table now, after few months when new UniqueIdentifier gets generated as part of our ETL, which is once a day, should not cause duplicates.

Please help.
Lynn Pettis
Lynn Pettis
SSC-Forever
SSC-Forever (41K reputation)SSC-Forever (41K reputation)SSC-Forever (41K reputation)SSC-Forever (41K reputation)SSC-Forever (41K reputation)SSC-Forever (41K reputation)SSC-Forever (41K reputation)SSC-Forever (41K reputation)

Group: General Forum Members
Points: 41182 Visits: 38567
Mac1986 (2/5/2013)
Hi All,
I have a table in which one of the column is UniqueIdentifier. I have NULLS from records 1 through 91 and then after I have records populated in the table. I need to fill up the NULLS with UniqueIdentifier. Can you please help me.

My only concern is if I update the table now, after few months when new UniqueIdentifier gets generated as part of our ETL, which is once a day, should not cause duplicates.

Please help.




update dbo.MyTable set
UniqueIdentifierCol = newid()
where
UniqueIdentifierCol is null;




Chances of a dup are quite low, but not impossible.

Cool
Lynn Pettis

For better assistance in answering your questions, click here
For tips to get better help with Performance Problems, click here
For Running Totals and its variations, click here or when working with partitioned tables
For more about Tally Tables, click here
For more about Cross Tabs and Pivots, click here and here
Managing Transaction Logs

SQL Musings from the Desert Fountain Valley SQL (My Mirror Blog)
Go


Permissions

You can't post new topics.
You can't post topic replies.
You can't post new polls.
You can't post replies to polls.
You can't edit your own topics.
You can't delete your own topics.
You can't edit other topics.
You can't delete other topics.
You can't edit your own posts.
You can't edit other posts.
You can't delete your own posts.
You can't delete other posts.
You can't post events.
You can't edit your own events.
You can't edit other events.
You can't delete your own events.
You can't delete other events.
You can't send private messages.
You can't send emails.
You can read topics.
You can't vote in polls.
You can't upload attachments.
You can download attachments.
You can't post HTML code.
You can't edit HTML code.
You can't post IFCode.
You can't post JavaScript.
You can post emoticons.
You can't post or upload images.

Select a forum

































































































































































SQLServerCentral


Search