IIF
conditional or n-ary selection
What changes
- Input
- a condition or index and value list
- Output or change
- one of the inputs
- Return type
- Returns the data type with the highest precedence from the types in true_value and false_value. For more information, see Data Type Precedence (Transact-SQL).
Syntax at a glance
IIF( boolean_expression, true_value, false_value )
Work example
Choose between two scalar values for a short condition.
Use CASE when a condition has several branches or needs clearer review.
Check your work IIF is shorthand for CASE and follows CASE type and null rules.
Practice SQL
Open in SQL FlowSELECT IIF(7 >= 5, 'pass', 'retry') AS outcome;
Open Microsoft Learn for full syntax, permissions, and details for your version.