Link to home
Start Free TrialLog in
Avatar of ukerandi
ukerandiFlag for United Kingdom of Great Britain and Northern Ireland

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
ASKER CERTIFIED SOLUTION
Avatar of Kyle Abrahams, PMP
Kyle Abrahams, PMP
Flag of United States of America image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of ukerandi

ASKER

Great
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))

Open in new window