New IIF Function in SQL Server 2012
In this article I have described new IFF function in SQL Server 2012
function is used to check a condition. Suppose X>Y. In this condition a is the
first expression and b is the second expression. If the first expression
evaluates to TRUE then the first value is displayed, if not then the second value will display.
IIF ( boolean_expression, true_value, false_value )
DECLARE @X INT;
DECLARE @Y INT;
Select iif(@X>@Y, 50, 60) As IIFResult
In this example X=50 and
Y=60; in other words the condition is false. Select iif(@X>@Y, 50, 60) As
IIFResult. It returns
false value that is 60.