Take the 2-minute tour ×
Server Fault is a question and answer site for professional system and network administrators. It's 100% free, no registration required.

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)?

share|improve this question
add comment

1 Answer

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.

share|improve this answer
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.