Friday, March 23, 2012

Insert Uniqueidentifier after the fact

I have an existing table that i would like to add a uniquidentifier to
each record of the table. I have already create a column for the
uniqueid. What sql script could I run to actually place a value for
the newly created column for each record?
thanks for your help ahead of timeWhat sql script could I run to actually place a value for

Quote:

Originally Posted by

the newly created column for each record?


You can use NEWID() to backfill existing data:

UPDATE dbo.MyTable
SET MyColumn = NEWID()

--
Hope this helps.

Dan Guzman
SQL Server MVP

<pltaylor3@.gmail.comwrote in message
news:1157114291.688642.258140@.b28g2000cwb.googlegr oups.com...

Quote:

Originally Posted by

>I have an existing table that i would like to add a uniquidentifier to
each record of the table. I have already create a column for the
uniqueid. What sql script could I run to actually place a value for
the newly created column for each record?
thanks for your help ahead of time
>

|||Thats perfect. Thanks for the help.
Dan Guzman wrote:

Quote:

Originally Posted by

Quote:

Originally Posted by

What sql script could I run to actually place a value for
the newly created column for each record?


>
You can use NEWID() to backfill existing data:
>
UPDATE dbo.MyTable
SET MyColumn = NEWID()
>
--
Hope this helps.
>
Dan Guzman
SQL Server MVP
>
<pltaylor3@.gmail.comwrote in message
news:1157114291.688642.258140@.b28g2000cwb.googlegr oups.com...

Quote:

Originally Posted by

I have an existing table that i would like to add a uniquidentifier to
each record of the table. I have already create a column for the
uniqueid. What sql script could I run to actually place a value for
the newly created column for each record?
thanks for your help ahead of time

No comments:

Post a Comment