Returns one of two values, depending on whether a given Boolean expression evaluates to true or false.
Parameters:
boolean_expression
evaluated to dtermine what value to returntrue_value
returned if boolean_expression
evaluates to truefalse_value
returned if boolean_expression
evaluates to falseSELECT IIF (42 > 23, 'I knew that!', 'That is not true.') AS iif_result
iif_result
------------
I knew that!
IIF
may be replaced by a CASE
statement. The above example my be written as
SELECT CASE WHEN 42 > 23 THEN 'I knew that!' ELSE 'That is not true.' END AS iif_result
iif_result
------------
I knew that!