(3)创建带输出参数的存储过程
use studb
go
if exists (select * from sysobjects where name = ''proc_stu'')
drop proc proc_stu
create proc proc_stu
@notpasssum int output,
@writtenpass int = 60,
@labpass int = 60
as
print ''笔试及格线:''+convert(varchar(20),@writtenpass)
print ''机试及格线:''+convert(varchar(20),@labpass)
print ''------------------------------------------------------------''
print ''参加本次考试没有通过的学员''
select stuname,stuinfo.stuno,writtenexam,labexam from stuinfo inner join stumarks
on stuinfo.stuno = stumarks.stuno
where writtenexam<@writtenpass or labexam<@labpass
select @notpasssum = count(stuno) from stumarks
where writtenexam<@writtenpass or labexam<@labpass
go
declare @sum int
exec proc_stu @sum output,64
print ''--------------------------------------------------------------''
if @sum>3
print ''未通过人数:''+convert(varchar(20),@sum)+''人,超过人数60%,及格分数线还应下调''
else
print ''未通过人数:''+convert(varchar(20),@sum)+''人,已控制在60%以下,及格分数线适中''
go
………………………………………………………………………………………………………………………………………………
>处理错误信息
use studb
go
if exists (select * from sysobjects where name = ''proc_stu'')
drop proc proc_stu
go
create proc proc_stu
@notpasssum int output,
@writtenpass int =60,
@labpass int = 60
as
if (not @writtenpass between 0 and 100) or (not labpass between 0 and 100)
begin
raiserror (''及格线错误,请指定0-100之间的分数,统计中断退出'',16,1)
return
end
print ''笔试及格线:''+convert(varchar(20),@writtenpass)+
'' 机试及格线:''+convert(varchar(20),@labpass)
print ''------------------------------------------------------------''
print ''参加本次考试没有通过的学员''
select stuname,stuinfo.stuno,writtenexam,labexam from stuinfo inner join stumarks
on stuinfo.stuno = stumarks.stuno
where writtenexam<@writtenpass or labexam<@labpass
select @notpasssum = count(stuno) from stumarks
where writtenexam<@writtenpass or&nbs