sqlserver带有输出参数的存储过程(output)定义存储过程时,同时制定输⼊及输出参数
⽤法:像是c语⾔的地址传递
语法:
-- @参数名数据类型[=默认值][OUTPUT][,....n]
例:输⼊学⽣的学号,统计该学⽣所选课程数,和不及格科⽬数,并调⽤存储过程显⽰结果
create proc prcGetStuInfo
@StuID char(10),
@SelectCount int output,
@FailCount int output
as
begin try
if exists(select*from Student where StuID =@StuID)
begin
select@SelectCount=count(*)from SC where StuID =@StuID
select@FailCount=count(*)from SC where StuID =@StuID and Score<60
end
else
print'info does not exist'
end tryoutput的反义词
begin catch
print'error!'
end catch
declare@SelectCount int
declare@FailCount int
exec prcGetStuInfo 'A00001',@SelectCount output,@FailCount output
print@SelectCount
print@FailCount

版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系QQ:729038198,我们将在24小时内删除。