要求是:创建存储过程proc1(),用指定的学号查询该学生所有课程成绩。
但不知道为什么报错,有人解答一下吗?
创建一个存储过程,用于查询指定课程号的课程
--是否被学生选修,如果有学生选修,
--则在该过程中设置一个输出参数用于
--返回选修该课程的学生人数,
--然后让该过程返值1,
--如果没有被任何一个学生选修,则该过程返回值2。
IF exists (select* from sys.objects where name='CunChu_lx_cno_course' and type='p' )
drop proc CunChu_lx_cno_course
go
create procedure CunChu_lx_cno_course
@out int output,
@in varchar(10)=1
as
select @out=count(*)from sc
where cno=@in
if(@out=0)
begin
set @out='2'
end
else
begin
set @out='1'
end