Monday, February 20, 2012

Is Null

Does anybody have an idea why this query is not working in SQL Server?

select * from users where designation is null

The table has numerous rows where the designation value is NULL. Is this a db setting that needs to be changed?

Thanks!

Maybe the values aren't null? Could they be an empty string? Try returning the length of each value for the relevant rows and see what it comes back with.

|||

select * from users where IsNull(designation, '') = ''

That will handle all null values along with any empty string values.

|||

It turned out that NULL was being stored as a string in that field. I may have changed the field from allowing nulls to not allowing nulls and in the process, those NULL values were converted to a string. At least that's my theory.

Thanks for your help!

No comments:

Post a Comment