T-SQL Tutorial

NULLIF


In SQL Server, the NULLIF expression is used to check whether two expressions are equal and return NULL.


NULLIF Syntax:

NULLIF(expression_1, expression_2)


NULLIF Example:

select NULLIF ( 'aaa' , 'aaa' ) as col_1,
NULLIF ( 'bbb' , '3' ) as col_2,
NULLIF ( 'ccc' , null ) as col_3;

col_1col_2col_3
NULLbbbccc

See also: T-SQL Functions -> COALESCE | HOST_ID | HOST_NAME | ISNULL | ISNUMERIC