如何使用一个输入和SQL Server一个输出参数2008
问题描述:
create procedure spGetEmployeByDepartmentIdCount
@DepartmentIdType int ,
@DepartmentIdCount int output
as
Begin
select count(id)
from tblemploye1
where @DepartmentIdType = id
End
Declare @DepartmentIdCount int
Declare @id int
set @id = 1
Execute spGetEmployeByDepartmentIdCount @id, @DepartmentIdCount output
print @DepartmentIdCount
答
你的存储过程返回仅选择数据 既然你没有指派到输出参数的任何值,它是NULL
你可以改变你的存储程序代码如下所示使用ALTER语句
select
@DepartmentIdCount = count(id)
from tblemploye1
where
id = @DepartmentIdType
现在输出参数在所选部门 分配与员工的计数我希望它能帮助
使用函数,它将返回值 –
所以有什么问题? – Sunil
它可以工作,任何问题? –