In an existing sql server 2012 database, there are lots of columns defined as (bit,null). When the value is checked to be = 0, the results are returned past. However when I check is made to see if the value = 1, then the results take forever to return.
For example when a field called test1 is defined as (bit,null) and the check is where test1 = 1, the query takes forever to run.
I am looking for a way to make these type of queries run fast.
When I change the above to 'where cast(test1 as int) = 1' the query executes faster. However, can you tell me if the sql I listed is a good solution? Should I check for null values?
Basically would you show me the 'best' sql to use in this case?