ukerandi
asked on
T-sql Where Clause
Hi
I need to get answer if Quarter not equal then I need to use Parameter @P2 else i need get all records
see my code below and idea is appriciate
T1.Quarter IN (CASE WHEN @P2<>'<All>' THEN @P2 ELSE LIKE '%' END)
AND
T1.Year IN (CASE WHEN @P3<>'<All>' THEN @P3 ELSE LIKE '%' END)
I have to use IN Key work ,I cant use Like becuase i need to pass several parameters.This for MS Report 2014, I need to select multiple paratemeters
I need to get answer if Quarter not equal then I need to use Parameter @P2 else i need get all records
see my code below and idea is appriciate
T1.Quarter IN (CASE WHEN @P2<>'<All>' THEN @P2 ELSE LIKE '%' END)
AND
T1.Year IN (CASE WHEN @P3<>'<All>' THEN @P3 ELSE LIKE '%' END)
I have to use IN Key work ,I cant use Like becuase i need to pass several parameters.This for MS Report 2014, I need to select multiple paratemeters
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
I was thinking about this last night and realized it could be made simpler:
where
(@P2 = '<All>' or T1.Quarter in (@P2)) AND
(@P3 = '<All>' or T1.Year in (@P3))
ASKER