If you try to get the value from other parts of the SQL you have to run this SP like this:
DECLARE @RV AS INT
EXEC @RV = FindAnnualLeave1(1)
SELECT @RV
From code you should use the ExecuteScalar method:
http://msdn.microsoft.com/en-us/library/37hwc7kt.aspx[
^]
---
An other option is to do
SELECT @AnnualPending
instead of
RETURN @AnnualPending
, but it mostly depends on your design...
Alter Proc [dbo].[FindAnnualLeave1]
@Empid varchar(20)
as
Declare @AnnualPending int
Select @AnnualPending =(select (0.0821917808219178) *
DATEDIFF(d, e.doj,GETDATE())- l.Leaves where l.EmpLeaveCode='Annual')
From EmployeeLeaves l
inner join EmployeeMaster e on l.EmpID=e.EmpID
where l.EmpID=e.EmpID
select @AnnualPending
Go