Hi!,
I'm passing in an optional parameter to a store proc and would like to add it to the were clause if the optional parameter is not NULL. (This case does not work)
/* @Allowance is my optional parameter
WHERE
dateYY Between @StartYr And @EndYr
and ACC_No Between '25000000' And '28000000'
CASE WHEN @Allowance is not null then
AND Job_Desc = @Allowance
END
Can someone tell me what I'm doing wrong and if I can have a case in the where clause?
Thanks
I'm passing in an optional parameter to a store proc and would like to add it to the were clause if the optional parameter is not NULL. (This case does not work)
/* @Allowance is my optional parameter
WHERE
dateYY Between @StartYr And @EndYr
and ACC_No Between '25000000' And '28000000'
CASE WHEN @Allowance is not null then
AND Job_Desc = @Allowance
END
Can someone tell me what I'm doing wrong and if I can have a case in the where clause?
Thanks