存储过程 输出参数不能超过1一个以上???

来源:百度知道 编辑:UC知道 时间:2024/06/24 05:08:05
if exists(select * from sysobjects where name='doctorSelectPage')
drop proc doctorSelectPage
go
create proc doctorSelectPage
@sum int output,
@departmentName varchar(20) output,
@ID int=1,
@departmentNameID int
as
select @departmentNameID=departmentID from doctor where doctorID=@ID
select @sum=count(doctorName) from doctor
select @departmentName=departmentName from department where departmentID in (select departmentID from doctor where departmentID=@departmentNameID)
select * from doctor where doctorID=@ID
go
declare @sum1 int
declare @name varchar(10)
exec doctorSelect @sum1 output,@name,1
print @sum1+@name

居然会提示“为过程或函数 doctorSelect 指定的参数太多。”!!!!!

exec doctorSelect @sum1 output,@name,1
很显然,您的存储过程名写错了,应该是
exec doctorSelectPage @sum1 output,@name,1,1

对于doctorSelectPage为名的存储过程,不但参数没有多,而且还少了一个

您的数据库里有一个doctorSelect为名的存储过程
而对于doctorSelect为名的存储过程,参数一定是多了,您看一下吧。

可以的.

象这样写

declare @sum1 int
declare @name varchar(10)
declare @ID int
set @ID =1
declare @departmentNameID int
set @departmentNameID =1

exec doctorSelectPage @sum1 output,@name,@ID,@departmentNameID
print @sum1+@name