注册 登录
编程论坛 SQL Server论坛

请问我的这个存储过程哪里有错误?

那个梦 发布于 2007-11-18 11:06, 786 次点击
create procedure pro (@sname_in char(12))
declare @cname_out char(20),@score_out char(4),
@tname_out char(12)
as
select @cname_out=cname,@score_out=score,@tname_out=tname
from student a , course b ,sc c, teacher d, tc e
where a.sno=c.sno and b.cno=c.cno and c.cno=e.cno and e.tno=d.tno
and a.sname=@sname_in

报错:服务器: 消息 156,级别 15,状态 1,过程 pro,行 2
在关键字 'declare' 附近有语法错误。
服务器: 消息 156,级别 15,状态 1,过程 pro,行 4
在关键字 'as' 附近有语法错误。
8 回复
#2
那个梦2007-11-18 11:06
盼高人指点啊
#3
purana2007-11-18 11:30

看看存储过程的基础语法.

create procedure pro (@sname_in char(12))

as
declare @cname_out char(20),@score_out char(4),
@tname_out char(12)
select @cname_out=cname,@score_out=score,@tname_out=tname
from student a , course b ,sc c, teacher d, tc e
where a.sno=c.sno and b.cno=c.cno and c.cno=e.cno and e.tno=d.tno
and a.sname=@sname_in
go

#4
那个梦2007-11-18 14:00

真是什么感谢你啊..你真的很厉害啊..可以拜师吗?

#5
purana2007-11-18 14:15
拜师..免了.
#6
卡卡艾2007-11-18 21:29
不要搞个人崇拜..呵呵...
#7
那个梦2007-11-20 10:06
有了偶像也是一件好事情呀...
#8
lhj20052007-11-20 13:05
有个小问题,我如何查询,或则查看我已经建立的存储过程(SQL2005)
#9
nianshi2007-11-21 11:21
select @cname_out=cname,@score_out=score,@tname_out=tname 这三个变量 并不是Out型的变量 不能传回值吧 那给它们赋了值又有什么用呢 直接返回查询结果不就行了吗
1