asked on
The query that is errorenous :
Select EmpCode, LeaveShortName, sum(LeaveValue) As LeaveTaken From txnLeaveDebits Where EmpCode = '10050' And LeaveId = 'LV0001' and ApplicationType <> 10 and status <> 2 And dbo.fn_getFinid(fromdate,todate) = 'FY0002 ' Group By EmpCode, LeaveShortName
The user defined function : fn_getFinid
CREATE function fn_getFinid(@fromdate as datetime,@todate as datetime) returns varchar(6) begin Declare @FinYearid_fr as varchar(6) Declare @FinYearid_to as varchar(6) set @FinYearid_fr = (select finyearid from dbo.atFinancialYear where @fromdate between fromdate and todate ) set @FinYearid_to = (select finyearid from dbo.atFinancialYear where @todate between fromdate and todate ) if @finyearid_fr <> @finyearid_to set @finyearid_fr = null return @finyearid_fr end
Microsoft SQL Server 2005 is a suite of relational database management system (RDBMS) products providing multi-user database access functionality.Component services include integration (SSIS), reporting (SSRS), analysis (SSAS), data quality, master data, T-SQL and performance tuning. It includes support for managing XML data and allows a database server to be exposed over web services using Tabular Data Stream (TDS) packets encapsulated within SOAP (protocol) requests.
TRUSTED BY