bugl
bugl
HomeLearnPatternsPathsSearch
HomeLearnPatternsPathsSearch

Loading lesson path

Learn/SQL/SQL References
SQL•SQL References

SQL Server IIF() Function

Flash cards

Review the key moves

1/4
Core idea

What is the main idea behind SQL Server IIF() Function?

Lesson checks

Practice each idea before moving on

Short Mimo-style checks built from this lesson's code, terms, and sequence.

1Quick choice

Which statement best captures the main point of this lesson?

2Fill blank

Complete the missing token from the example code.

___(500<1000, 'YES', 'NO');
3Order

Put the learning moves in the order that makes the concept easiest to apply.

The IIF() function returns a value if a condition is TRUE, or another value if a condition is FALSE.
Definition and Usage
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