0x49D1
0x49D1

Reputation: 8704

Replace BIT values with some text

I have a BIT column with gender (0,1) and want to replace 0 and 1 in the resulting view with the words "man" and "woman". Can i do this right in the view with some system finction or i have to write my own function to do that?

Upvotes: 0

Views: 1996

Answers (1)

AdaTheDev
AdaTheDev

Reputation: 147274

You can just use a CASE statement like below. Think about what you're trying to do though - perhaps it would be better to return 0 and 1, but convert to the right text in the UI...that's what I'd do.

SELECT CASE Gender WHEN 0 THEN 'Man' WHEN 1 THEN 'Woman' END AS Gender
FROM YourTableOrView

Upvotes: 3

Related Questions