Hello,
AND b.fired_day LIKE (CASE WHEN @type = 'b' THEN '%' WHEN @type= 'l' THEN '-1' WHEN @type= 'o' THEN '0' END)
I want the following thing:
When type= b, then show everything
When type=l, then show the items that aren't filled in
When type=o, then show the items that are filled in
What's wrong with my code (b.fired_day is a date)

Items that are filled in
jam281
mars76
I am assuming the '-1' and '0' clauses are coming from ACCESS.
I think to achieve what you want in SQL server you either need to write a dynamic SQL query or an if-then-else statement like below:
IF @type = 'b'
BEGIN
select * from TABLE
END
ELSE IF (@type = 'l')
BEGIN
select * from TABLE
where fired_day IS NULL
END
ELSE
BEGIN
select * from TABLE
where fired_day IS NOT NULL
END
clientserver
Robbiex
Well this is the closest to your request I could come.... Let me know if you work out something better:
select * from tblName
where ISNULL(CAST(fired_day as varchar),'-1') LIKE (CASE WHEN @type = 'b' THEN '%' WHEN @type = 'l' THEN '-1' END)
OR fired_day LIKE (CASE WHEN @type = 'o' THEN '%' END)
ctharris
Have you tried the code....
the code accomplishes all req...