i have a simple tab开发者_开发百科le \"MyTable\" with single colum \"id\" which type is uniqueidetifier and rowguid is set to true. I insert new values like this
i have a simple tab
开发者_开发百科le "MyTable" with single colum "id" which type is uniqueidetifier and rowguid is set to true. I insert new values like this
INSERT INTO MyTable
DEFAULT VALUES
how to get inserted by server guid ?
Best Regards,
Iordan
Assuming you are on at least SQL Server 2005 use the OUTPUT
clause.
DECLARE @MyTable TABLE
(
id UNIQUEIDENTIFIER DEFAULT NEWID()
)
INSERT INTO @MyTable
OUTPUT inserted.id
DEFAULT VALUES
精彩评论