1

I was asked this on an interview, and would like some feedback...

I have a stored procedure that takes in a varchar parameter IsActive that is either a "YES" or "NO" string.

The stored procedure will query a table that has an Active column with a datatype of bit. If the parameter is "YES" then it will return all rows with an Active column bit value of 1, otherwise for "NO" it will return all rows with an Active column bit value of 0.

Is it best to convert the parameter value from YES/NO to 1/0, or convert the table data from 1/0 to YES/NO when querying?

Is the answer the same if the datatypes are reversed (1/0 being passed in, YES/NO stored in the table)?

1 Answer 1

0

I would think that it's better to convert the parameter from "YES"/"NO" to 1/0 to avoid having to store the more space consuming varchars in the database.

I also think that a query that filters on bit types will be more efficient at searching than one that filters on varchars.

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .