New IIF Function in SQL Server 2012
In this article I have described new IFF function in SQL Server 2012
IIF() Function
The IIF 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.
Syntax
IIF ( boolean_expression, true_value, false_value )
Example
DECLARE @X INT;
SET @X=50;
DECLARE @Y INT;
SET @Y=60;
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.
Output