create proc stu_7 @sid int,@sname char(5) output,@sscore int output
as
begin
select @sname=stu_name,@sscore=stu_score
from student where stu_id=@sid;
enddeclare @sname char(5),@sscore int
set @sname='' set @sscore=0
exec stu_7 1,@sname=@sname output,@sscore=@sscore output
begin
select stu_id,stu_name,stu_score from student
where stu_id=1 and stu_name=@sname and stu_score=@sscore
end使用带输出参数的存储过程,通过输出参数@sname和@sscore获得表中的对应字段的值,但输出老是空的。
或这样试试
exec stu_7 1,@sname output,@sscore output
2.自己手动赋值检查select stu_id,stu_name,stu_score from student
where stu_id=1 and stu_name=@sname and stu_score=@sscore是否调用如预期所想。