• arthur.teter (10/19/2012)


    While I know you are not supposed to be able to add multiple GUIDs to any table, on the systems I have worked on I have found that with table variables it is possible. When I run the following I do not get any errors

    declare @TableVar table(MyID INT IDENTITY PRIMARY KEY CLUSTERED

    , NEXTFIELD varchar(10), nextfield2 varchar(10)

    , ROWGUID UNIQUEIDENTIFIER

    , ROWGUID2 UNIQUEIDENTIFIER

    )

    insert into @TableVar (NEXTFIELD, nextfield2, ROWGUID, ROWGUID2)

    values ('Test1', 'TEST1', NEWID(), NEWID())

    , ('Test2', 'TEST2', NEWID(), NEWID())

    , ('TEST3', 'HOW', NEWID(), NEWID())

    select * from @TableVar

    Actually, there's a misprint in the question (my stupid error) - it should say @ROWGUIDCOL, not ROWGUID. You can have as many rowguid columns as you like in any kind of table (just as you can have as many int columns as you like in any kind of table - after all, rowguid is a type like any other type), but only one of them can have the ROWGUIDCOL property (just as only one column can have the IDENTITY property). I'll ask Steve to correct that wording (and 2011) if possible.

    Tom