bugl
bugl
HomeLearnPatternsPathsSearchPremium
HomeLearnPatternsPaths

Loading lesson path

Learn/SQL/SQL References
SQL•SQL References

SQL Server IIF() Function

Example

SELECT
IIF(500<1000, 'YES', 'NO');

Definition and Usage

The IIF() function returns a value if a condition is TRUE, or another value if a condition is FALSE.

Syntax

IIF(
condition
,
value_if_true
,
value_if_false
)

Parameter Values

ParameterDescription
conditionRequired. The value to test
value_if_trueOptional. The value to return if condition is TRUE
value_if_falseOptional. The value to return if condition is FALSE

Technical Details

Works in:SQL Server (starting with 2012), Azure SQL Database

Previous

SQL Server CURRENT_USER Function

Next

SQL Server ISNULL() Function