By searching a number of SO threads I am unable to write a query which returns the appropriate condition in the where clause.
For example I have column Col1 which is int and a variable var1 as varchar now I used below query but it is not working.
Where CASE WHEN var1 = '1' THEN (Col1 = 1)
WHEN var1 = '2' THEN (Col1 = 2)
ELSE AND (1= 1)
END
It gives me syntax error near '='.
EDIT:
What If I want condition like
Col1 IN (condtions….)
I think it should be like;
OR
As a side note, if
Col1 is nullableandneed to selectthose as well then use;