Loading lesson path
Concept visual
Start at both ends
Return "YES" if the condition is TRUE, or "NO" if the condition is FALSE:
IIF(500<1000, 'YES', 'NO');The IIF() function returns a value if a condition is TRUE, or another value if a condition is FALSE.
condition, value_if_true, value_if_false )
Required. The value to test value_if_true
Optional. The value to return if condition is TRUEvalue_if_false
Optional. The value to return if condition is FALSESQL Server (starting with 2012), Azure SQL Database
Return 5 if the condition is TRUE, or 10 if the condition is FALSE:
SELECT IIF(500<1000, 5, 10);Test whether two strings are the same and return "YES" if they are, or "NO" if not:
SELECT IIF('hello' = 'bye', 'YES', 'NO');Return "MORE" if the condition is TRUE, or "LESS" if the condition is FALSE:
SELECT OrderID, Quantity, IIF(Quantity>10,
'MORE', 'LESS')OrderDetails;❮ SQL Server Functions