日期:2014-05-18  浏览次数:20517 次

返回上一句SQL语句生成的GUID
INSERT INTO T_PGM_ViewRole(ID) SELECT NEWID()
我下面的一条SQL语句要用到这个新产生的GUID 我如何得到这个GUID啊?


------解决方案--------------------
SQL code

decare @t table (guid guid)

INSERT INTO T_PGM_ViewRole(ID)
output into @t(guid)
 SELECT NEWID()
--从表@t里获取

------解决方案--------------------
SQL code
decare @t table (guid guid)

INSERT INTO T_PGM_ViewRole(ID)
output inserted.ID into @t
 SELECT NEWID()
--从表@t里获取

------解决方案--------------------
没闹啊。。
------解决方案--------------------
SQL code
create proc pr_name(@id nvarchar(30) out)
as
begin
    set @id=NEWID()
    INSERT INTO T_PGM_ViewRole(ID) SELECT @id
end

declare @id nvarchar(30) 
exec pr_name @id output
print @id

------解决方案--------------------
探讨
SQL code
create proc pr_name(@id nvarchar(30) out)
as
begin
set @id=NEWID()
INSERT INTO T_PGM_ViewRole(ID) SELECT @id
end

declare @id nvarchar(30)
exec pr_name @id output
print @id……