+_+ 看错了--2005 set nocount on begin dclare @t table([filename] [uniqueidentifier]) insert into [photo]([uid]) output inserted.filename into @t(filename) selec @uid select @filename=filename from @t ---此处怎么取得刚插入的数据,主要是[filename] end GO
你可以换一个思路 先生成newid() 再插入 create procedure [dbo].[photo_upload] @uid [int], @filename [varchar] (36) output AS set nocount on begin set @filename=newid() insert into [photo] (filename,[uid]) values (@filename,@uid) --能够达到同样的目的,这样不就省事了很多 end GO
没有identity列,uid只是个外键约束
+_+ 看错了--2005
set nocount on
begin
dclare @t table([filename] [uniqueidentifier])
insert into [photo]([uid]) output inserted.filename into @t(filename) selec @uid
select @filename=filename from @t
---此处怎么取得刚插入的数据,主要是[filename]
end
GO
create procedure [dbo].[photo_upload]
@uid [int],
@filename [varchar] (36) output
AS
set nocount on
begin
set @filename=newid()
insert into [photo] (filename,[uid]) values (@filename,@uid)
--能够达到同样的目的,这样不就省事了很多
end
GO
楼主放心的生成guid再插入吧
再说,如果生成的guid会重复的话,楼主的default(newid()) 也有可能是重复的
所以,放心的直接先生成就可以了