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_1 | col_2 | col_3 |
---|---|---|
NULL | bbb | ccc |
See also: T-SQL Functions -> COALESCE | HOST_ID | HOST_NAME | ISNULL | ISNUMERIC