Click here to monitor SSC
SQLServerCentral is supported by Red Gate Software Ltd.
 
Log in  ::  Register  ::  Not logged in
 
 
 
        
Home       Members    Calendar    Who's On


Add to briefcase

How to generate UniqueIdentifiers and insert in a column Expand / Collapse
Author
Message
Posted Tuesday, February 5, 2013 8:37 PM
SSC Veteran

SSC VeteranSSC VeteranSSC VeteranSSC VeteranSSC VeteranSSC VeteranSSC VeteranSSC Veteran

Group: General Forum Members
Last Login: Sunday, September 14, 2014 1:28 AM
Points: 219, Visits: 693
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.
Post #1416209
Posted Tuesday, February 5, 2013 9:00 PM


SSC-Insane

SSC-InsaneSSC-InsaneSSC-InsaneSSC-InsaneSSC-InsaneSSC-InsaneSSC-InsaneSSC-InsaneSSC-InsaneSSC-InsaneSSC-Insane

Group: General Forum Members
Last Login: Today @ 1:42 AM
Points: 20,799, Visits: 32,717
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.



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)
Post #1416217
« Prev Topic | Next Topic »

Add to briefcase

Permissions Expand / Collapse