I have column "Status" of bit type in a table and in the declaration of parameters I have defaulted it to 0 and I have few other parameters coming in with defaulted to null
@FirstName varchar(20) = null,
@LastName varchar(20) = null,
@Status bit = 0
and my sql is something like
Select * from customers where
(ISNULL(@FirstName,'') ='' OR FirstName= @FirstName)
AND (ISNULL(@LastName,'') ='' OR LastName= @LastName)
AND (Status = @Status)
The situation is if only @FirstName value is sent from the code and the Value of the column "Status = 1" in the table and no value for @Status is sent, then since it @Status defaults to 0 no records get returned. How to deal with the bit type, in a situation where the parameter for the bit type is not sent and the value for it in the table is 1.
()bracketing.