Sorry if it is asked before, I really searched but could not find.
What I am trying to do is to assign 'null' or 'not null' to a varchar variable depending on a parameter in MS SQL. On the first one, The user would only see the description if he/she selects 1 as index. On the second one, the user would see the description if the year column is larger than 2005 for a record. The code I am trying is below but not working. Can someone help me on this logic please? Really appreciated.
Thanks.
--- First one---
Declare @index int;
Select * from Cars
Where Description is (case when @index = 1 then ‘not null’ else ‘null’ end)
---Second one----
Select * from Cars
where Description is (case when Cars.Year > 2005 then ‘not null’ else ‘null’ end)