Wednesday, January 26, 2022

sql server - How to use IFF instead of CASE

Since 2012+ version can be used IFF statement (similar like DECODE() in Oracle):
select todate 
from pricedisctable
where
itemrelation = 'S-331-123-2056';

select IIF( todate='1900-01-01 00:00:00.000', null, todate ) 
from pricedisctable
where
itemrelation = 'S-331-123-2056';
Output: