Articles → SQL SERVER → IIF Function In The SQL Server
IIF Function In The SQL Server
Purpose
Syntax
IIF(condition, value_if_true, value_if_false)
Example
Declare @number as int
Set @number = 1
SELECT IIF(@number %2 = 0 , 'Even', 'Odd');
Set @number = 2
SELECT IIF(@number %2 = 0 , 'Even', 'Odd');
Output