if exists (select * from sysobjects where name = 'proc_stu') drop proc proc_stu go create proc proc_stu @passnum int output, @writtenPass int = 60,----输入参数,笔试及格线 @LabPass int = 60 ---- 输入参数,机试及格线 as print '参加本次考试没有通过的学员' select stuinfo.stuName,stuinfo.stuNo ,stuMarks.writtenExam,stuMarks.LabExam from stuinfo inner join stuMarks on stuMarks.stuNo=stuinfo.stuNo where writtenExam<@writtenPass or LabExam<@LabPass select @passnum=count(stuNo) from stuMarks where writtenExam<@writtenPass or LabExam<@LabPass
declare @pass int ---声明变量接受输出的参数 exec proc_stu @pass output ,100,90 if(@pass>=3) begin print '不及格人数过多' end else begin print '不及格人数合格' end
参加本次考试没有通过的学员 stuName stuNo writtenExam LabExam ---------- ---------- ----------- ---------- 张秋丽 s25301 87 82 李斯文 s25303 90 58 李文才 s25302 60 90
(所影响的行数为 3 行)
不及格人数过多