select NULL and false but not true in sql

The selection should be done on the SQL Server's side. Your query should look like this:

SELECT *
FROM MyTable
WHERE activated = 0 OR activated is NULL

The above assumes that the column activated is of an integral or a BIT data type.

Note: it may be tempting to use a seemingly equivalent WHERE activated <> 1 condition. This would be incorrect, though, because comparisons of NULL values to anything result in a NULL, so the rows with activated = NULL would be excluded.


You should be able to do a coalesce on the field to get it to false if it is null. A coalesce statement checks to see if the first parameter is null, if it is it returns the value in the second parameter. There would be two solutions:

SELECT *
FROM MyTable
WHERE COALESCE(activated,'false') <> 'true'`

--OR--

SELECT *
FROM MyTable
WHERE activated = 'false' or activated is null

With SQL's 3-valued logic, comparisons for NULL need to be done using the IS NULL operator... the check for false can be done with =:

SELECT YourColumn
FROM YourTable
WHERE 
  YourColumn IS NULL 
  OR YourColumn = 0