创建
create proc 存储过程名称
@id char(10),
@字段变量名称1 varchar(20),
@字段变量名称2 varchar(50),
@返回值变量 int output
as
begin try
insert into 表名 values(@id, @字段变量名称1,@字段变量名称2)
set @返回值变量=1
end try
begin catch
set @返回值变量=@@ERROR
--辅助信息
--select ERROR_LINE() as Line,
-- ERROR_MESSAGE() as message1,
-- ERROR_NUMBER() as number,
-- ERROR_PROCEDURE() as proc1,
-- ERROR_SEVERITY() as severity,
-- ERROR_STATE() as state1
end catch
使用
declare
@rtn int
exec 存储过程名称 "114","变量值1","变量值2",@rtn output
print @rtn