存储过程获取新插入记录ID

create procedure sp_AddUser1
@Name nvarchar(200),
@Remark nvarchar(200),
@Flag int
as
begin
declare @id int
insert into User(Name,Remark,Flag) values(@Name, @Remark,@Flag)
set @id = scope_identity()
update User set Sort=@id where ID=@id
end

 

create procedure sp_AddUser2
@Name nvarchar(200), 
@Remark nvarchar(200),
@Flag int,
@id int output
as 
begin 
insert into User(Name,Remark,Flag) values(@Name, @Remark,@Flag)
set @id = scope_identity()
end

 

posted @ 2014-12-30 16:32  随学·笔记  阅读(457)  评论(0编辑  收藏  举报