Results 1 to 2 of 2

Thread: Rowguid Column

  1. #1
    Join Date
    May 2009
    Posts
    41

    Rowguid Column

    I have a question regarding 'rowguid' column.
    I have created a table that includes a rowguid column.
    The syntex that i used to create the table is as below:

    Create table mytable
    (
    process_id uniqueidentifier,
    Date datetime,
    processdesc nvarchar(300)
    )

    Now, the inserts in this table are giving me the values as nulls for process_id column.
    Then, I came to know the correct syntex would have been
    Create table mytable
    (
    process_id uniqueidentifier default newid(),
    Date datetime,
    processdesc nvarchar(300)
    )

    default newid() is given in order to generate a unique value to the column.
    Now i dont want to recreate the table aftre dropping.
    I just want to alter the table by just adding 'default newid()' to it.

    How can i do that????

    thanks

  2. #2
    Join Date
    Nov 2002
    Location
    New Jersey, USA
    Posts
    3,932
    Try

    ALTER TABLE .. ATLER COLUMN .. default newid()

    If that doesn't work, then update should work

    You can run UPDATE with set process_id=newid()

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •