Stefan Steiger
Stefan Steiger

Reputation: 82186

Inserting a GUID to each existing row

question concerning SQL Server:

I have added a column with type uid to a table with already existing data.

How can I insert a guid in each row of this existing table?

(I mean without reading out the data with a dataadapter, adding a guid for each row and the updating the table [unless there is a method to automatically generate the update command])

Upvotes: 1

Views: 750

Answers (2)

Omar
Omar

Reputation: 40182

Do it in SQL by running a query against your database. You could use SQL Server Management Studio.

UPDATE table_name
SET column_name = newid()

Upvotes: 4

brendan
brendan

Reputation: 29976

I think this would work:

   Update mytable 
   Set idcolumn = newid()

Upvotes: 3

Related Questions