I have a store procedure that expects a parameter "@Abnormality bit". Based on the value true, false or null, the query returns all rows with true , false or all values respectively.
I am using the isnull function to check the value, however I get the following 3 faulty condition.
if i use (isnull(@Abnormality,1) = 1 OR Report.abnormalflag = @Abnormality) then 1 and null return all rows
if i use (isnull(@Abnormality,0) = 0 OR Report.abnormalflag = @Abnormality) then 0 and null return all
if i use (isnull(@Abnormality,null) = null OR Report.abnormalflag = @Abnormality) then null return nothing
Please advice.
I am using the isnull function to check the value, however I get the following 3 faulty condition.
if i use (isnull(@Abnormality,1) = 1 OR Report.abnormalflag = @Abnormality) then 1 and null return all rows
if i use (isnull(@Abnormality,0) = 0 OR Report.abnormalflag = @Abnormality) then 0 and null return all
if i use (isnull(@Abnormality,null) = null OR Report.abnormalflag = @Abnormality) then null return nothing
Please advice.