Insert Uniqueidentifier after the fact

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • pltaylor3@gmail.com

    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 time

  • Dan Guzman

    #2
    Re: Insert Uniqueidentifie r after the fact

    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@gmai l.comwrote in message
    news:1157114291 .688642.258140@ b28g2000cwb.goo glegroups.com.. .
    >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
    >

    Comment

    • pltaylor3@gmail.com

      #3
      Re: Insert Uniqueidentifie r after the fact

      Thats perfect. Thanks for the help.
      Dan Guzman wrote:
      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@gmai l.comwrote in message
      news:1157114291 .688642.258140@ b28g2000cwb.goo glegroups.com.. .
      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

      Comment

      Working...