Search code examples
sqlsql-serversql-server-2012isnull

Why [table].[column] != null is not working?


Why select * from [table] where [table].[column] != null is not working for my query and result is empty.

But select * from [table] where [table].[column] is not null is working and find records that [table].[column] is fill with null!

What is the difference between != null and is not null in Microsoft SQL Server?


Solution

  • NULL in a database is not a value. It means something like "unknown" or "data missing".

    You cannot tell if something where you don't have any information about is equal to something else where you also don't have any information about (=, != operators). But you can say whether there is any information available (IS NULL, IS NOT NULL).

    IMHO, in practice it is not very useful. But it is how it is and has a long history.