sql - Trouble comparing smallint in where clause -


i have table column called status of type smallint , accepts null. sql server 2000.

my data contains 2 in field, 0 , null.

when

select * table  status <> 2 

i don't proper records (where status null or 0). idea why happening , how correct? shouldn't <> give me other 2?

select * table  isnull(status, 1) <> 2 

null doesn't compare: remove it.

your example "common mistake" on wikipedia too...


Comments