I have a table with 100 records with no PK.
I need to add random GUID to it. Before:
First Name Last Name GUID
John Smith
Alex Smith
etc
After:
First Name Last Name GUID
John Smith 34234234gyerfw
Alex Smith werwer32r23r
etc
Currently I can do it by:
Creating an identity column with values, then make a while loop and generate newid(). Any option on how to do this without a loop?
Just add the empty column and then do an UPDATE.
ALTER TABLE YourTable
ADD GUID UNIQUEIDENTIFIER
UPDATE YourTable
SET GUID = NEWID()
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With