Nullif and equal values The online documentation defines nullif() as a function which returns NULL if the argument values are equal. But why does it return NULL even if the argument values are not equal, as in the case below:

select nullif(convert(varchar(10), ' '), convert(varchar(10), ''))


----------
NULL

(1 row affected)
SQL server ignores trailing spaces when performing comparisons.  So ' ' is considered the same as ''.  The former is the latter with trailing spaces.