transforming from 'Y' or 'N' to bit

Posted by rap-uvic on Stack Overflow See other posts from Stack Overflow or by rap-uvic
Published on 2010-03-27T16:06:29Z Indexed on 2010/03/27 16:13 UTC
Read the original article Hit count: 313

Filed under:
|

Hello,

I have a table which has a column called Direct of type char(1). It's values are either 'Y' or 'N' or NULL. I am creating a view and I want the value to be transformed to either 0 or 1 of type bit. Right now it's of type INT. How do I go about doing this?

Following is the code:

CASE WHEN Direct = 'Y' THEN (SELECT 1)
WHEN Direct <> 'Y' THEN (SELECT 0) END AS DirectDebit

© Stack Overflow or respective owner

Related posts about tsql

Related posts about sql-server-2005