首页 诗词 字典 板报 句子 名言 友答 励志 学校 网站地图
当前位置: 首页 > 教程频道 > 开发语言 > VC/MFC >

哪儿出错了

2013-03-06 
哪里出错了create proc stu_7 @sid int,@sname char(5) output,@sscore int outputas beginselect @sname

哪里出错了


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;
end

declare @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获得表中的对应字段的值,但输出老是空的。

[解决办法]
检查stu_id=1有没记录?
或这样试试
exec stu_7 1,@sname output,@sscore output

[解决办法]
1.检查exec stu_7 1,@sname=@sname output,@sscore=@sscore output调用是否成功。
2.自己手动赋值检查select stu_id,stu_name,stu_score from student
where stu_id=1 and stu_name=@sname and stu_score=@sscore是否调用如预期所想。

热点排行