在sql server中,是否可以使用存储过程在插入某些值的表中返回标识列值?例如,如果我们在表中插入数据,则使用存储过程:
表TBL
因此,如果我运行存储过程,插入以下值:
Insert into TBL (Name, UserName, Password)
Values ('example', 'example', '$2a$12$00WFrz3dOfLaIgpTYRJ9CeuB6VicjLGhLset8WtFrzvtpRekcP1lq')如何返回进行此插入的UserID值。我需要一些其他操作的UserID值,有人能解决这个问题吗?
发布于 2013-08-01 12:10:42
Insert into TBL (Name, UserName, Password) Output Inserted.IdentityColumnName
Values ('example', 'example', 'example')发布于 2013-08-01 12:10:36
发送输出参数,如
@newId int output最终使用
select @newId = Scope_Identity()
return @newId 发布于 2013-08-01 12:12:11
https://stackoverflow.com/questions/17993606
复制相似问题