2017-12-18 257 views
0
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 
+0

使用函数,它将返回值 –

+1

所以有什么问题? – Sunil

+0

它可以工作,任何问题? –

回答

0

你的存储过程返回仅选择数据 既然你没有指派到输出参数的任何值,它是NULL

你可以改变你的存储程序代码如下所示使用ALTER语句

select 
    @DepartmentIdCount = count(id) 
from tblemploye1 
where 
    id = @DepartmentIdType 

现在输出参数在所选部门 分配与员工的计数我希望它能帮助

相关问题