Transact SQL Other Articles Software Reviews
Using the Transact SQL NullIf Statement
The Transact SQL NullIf function can be used to determine if two values are identical. If they are identical, then null is returned.
The NullIf function is called by passing in the two arguments for the values that need to be compared, e.g.:
select nullif(Salary, Bonus)
If the values are not identical, the first argument is returned.
Note that although NullIf can be used for comparisons betwee most Transact SQL data types, a syntax error will occur if comparisons are made between two non-comparable data types such as an integer and a string.