SQL Flow Field Guide

IIF

Catalog support for SQL Server 2022 (16.x) and 2025 (17.x)

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 Flow
SELECT IIF(7 >= 5, 'pass', 'retry') AS outcome;

Open Microsoft Learn for full syntax, permissions, and details for your version.