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)
Your stored procedure returns only SELECT data Since you did not assign any value to output parameter, it is NULL
You can change your stored procedure code as follows using ALTER statement
select
@DepartmentIdCount = count(id)
from tblemploye1
where
id = @DepartmentIdType
Now the output parameter is assigned with the count of employees in selected department I hope it helps