I just did some testing and found out something interesting. I wrote my queries like this:
SELECT * FROM TableA WHERE Val IS NOT NULL AND LEN(RTRIM(LTRIM(Val))) > 0
But you really don't need to check for null, all you have to do is check the length after trimming the value.
SELECT * FROM TableA WHERE LEN(RTRIM(LTRIM(Val))) > 0
This option preempts zeros, as well as any columns with a space.
As it turns out, you don't need to trim the value because SQL Server ignores trailing spaces, so all you really need is: SELECT * FROM TableA WHERE LEN (Val)> 0
Jim
source share