Skip to content
Advertisement

select NULL and false but not true in sql

i an new in vb.ner sql and what i am asking may be silly question. I have a table in sql server 2005 and a column name activated. this column contain NULL, true or false.

I want to select only NULL or false values. How can i do this?

Advertisement

Answer

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.

User contributions licensed under: CC BY-SA
7 People found this is helpful
Advertisement