I have a bit valued column that has entries 0, 1, NULL.
I need to show all entries where
bcode = 0
Since default 0 is not set for the column hence I need to handle the nulls.
To get all the entries that have null and 0 entry in the bit column I write below query
select code 
from tbl_sample 
where (bcode = 0 or bcode is null)
I'm not sure if this will returns both 0s and NULLs. But if it does to simply the above query will the below query work or will it result to wrong output?
select code 
from tbl_sample 
where isnull(bcode, 0) = 0
or
select code 
from tbl_sample 
where isnull(bcode, '') = 0
What is the right way?
bcode=0 OR bcode IS NULL.bcodeCOALESCEis as bad asISNULLand forces a full table scan