Tag: NULLIF in SQL Server

NULLIF() in SQL Server

NULLIF – (Definition by Microsoft) returns NULL if the two expressions are equal and if the expressions are different then returns the first expression.

A simple representation as below:

Select NULLIF(100,100),NULLIF(100,101)

Another way of representing

Case when Expression1 = Expression2 Then NULL Else Expression1 End

It is important to be aware that non-deterministic functions may have an impact since it evaluates two times and returns different values. Eg. NEWID(), RAND() etc.

I’d like to grow my readership. If you enjoyed this blog post, please share it with your friends!