February 17, 2006 at 7:43 am
Can anyone give me a suggestion on the best way to do this? I have a table with about 3000 records. There is a particular column that is Null for all records. I would like to create a unique value in this field for each record. It does not really matter what this value is. I have had two thoughts on how to go about this.
The first, which I am not sure how to do, would generate a randomly generated 6-8 character value.
The second would involve writing a SQL from SQL statement to generate an update statement for each of the records while using another field's value concatenated with a static value. I have done similar things to this but never for this many records at once.
Is there another simpler way to do this that I am overlooking?
Again, the value that gets populated is not important, only that they are not all the same. Any thoughts on the best way to go about this?
Thanks
TJP8
February 17, 2006 at 8:57 am
update mytable
set col = substring( cast(newid()as varchar(80)), 1, 8)
February 17, 2006 at 11:37 am
Thanks Steve, this did exactly what I was looking to do.
TJP8
February 20, 2006 at 9:57 pm
You can also use:
ALTER TABLE TableName
ADD Column int identity(1,1)
Regards
Manoj Jain
Microsoft
Viewing 4 posts - 1 through 3 (of 3 total)
You must be logged in to reply to this topic. Login to reply