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


Picture showing the output of iif function in sql server





Posted By  -  Karan Gupta
 
Posted On  -  Thursday, February 16, 2023

Query/Feedback


Your Email Id
 
Subject
 
Query/FeedbackCharacters remaining 250