SELECT 'Equal'
WHERE ' ' = ''
Result:
-----
Equal
(1 row(s) affected)
SELECT 'Equal'
WHERE ' ' = ''
Result:
-----
Equal
(1 row(s) affected)
SQL Server does not consider trailing spaces when comparing strings using the = operator. That's why it considers ' ' to be equivalent to ''.
Here's a page that explains the semantics: http://support.microsoft.com/kb/316626
SQL Server evaluated ' ' = ''
as a boolean type that equated to TRUE, therefore it will return the string literal that you specified in your SELECT.
The same would occur with: SELECT 'Equal' WHERE 1=1