can we bind a stored procedure with if else condition to crystal report
Stored procedure Shown below
[sp_report_select_paymentsettlemnt_details]
@settlementperiodcode nvarchar(15),@fromdate datetime ,@todate datetime,@condition nvarchar(2)
AS
BEGIN
if @condition=3
--paysettled
BEGIN
SELECT *
FROM dbo.view_paymentsettlemnt_details as t1
WHERE settlementperiodcode =@settlementperiodcode and tdate>=@fromdate and tdate<=@todate and paymentsettlementid<>''
ORDER BY acccode, itemcode;
END
else if @condition=2
BEGIN
SELECT *
FROM dbo.view_paymentsettlemnt_details as t1
WHERE settlementperiodcode =@settlementperiodcode and tdate>=@fromdate and tdate<=@todate and paymentsettlementid=''
ORDER BY acccode, itemcode;
END
else
--all
BEGIN
SELECT *
FROM dbo.view_paymentsettlemnt_details as t1
WHERE settlementperiodcode =@settlementperiodcode and tdate>=@fromdate and tdate<=@todate
ORDER BY acccode, itemcode ;
END
END
It always give same result