开发者

Get value inserted in RowGuid?

开发者 https://www.devze.com 2023-01-21 03:55 出处:网络
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
0

精彩评论

暂无评论...
验证码 换一张
取 消