In a table I have created a new column that's going to hold a randomized alphanumeric string. I've been using the NEWID() function. From my understanding, NEWID should just create a new guid per row but all my rows end up with the same guid.
My code is:
DECLARE @random_guid
SET @random_guid = NEWID()
UPDATE this_table
SET random_column = @random_guid
Thanks in advance for any help!
That's probably cause you are setting the variable first and using it. Rather directly use the function like
UPDATE this_table
SET random_column = 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