dataengref migrate

Home / SQL Server

SQL Server IIF in Snowflake, Databricks and BigQuery

SQL Server IIF(cond, a, b) is IFF in Snowflake, if or iff in Databricks, and IF in BigQuery. Note the spelling: Snowflake and Databricks use IFF with one I and two Fs.

SQL Server function: IIF(boolean_expression, true_value, false_value) · SQL Server docs

Equivalents

TargetSupportSyntaxNotesSource
SnowflakeDifferent nameIFF(condition, expr1, expr2)Returns expr2 when the condition is FALSE or NULL.Snowflake docs
DatabricksDifferent nameiff(cond, expr1, expr2)Synonym of if(cond, expr1, expr2).Databricks docs
BigQueryDifferent nameIF(expr, true_result, else_result)Returns else_result when expr is FALSE or NULL.BigQuery docs

Behavior differences to check

Examples

Label large orders

SQL Server
SELECT order_id, IIF(amount >= 1000, 'large', 'regular') AS size FROM orders;
Snowflake
SELECT order_id, IFF(amount >= 1000, 'large', 'regular') AS size FROM orders;
Databricks
SELECT order_id, iff(amount >= 1000, 'large', 'regular') AS size FROM orders;
BigQuery
SELECT order_id, IF(amount >= 1000, 'large', 'regular') AS size FROM orders;

Other SQL Server functions

Last checked: · Paste a whole query into the SQL checker to find every function that needs a change.