user1789721
user1789721

Reputation: 87

Can I replace values of bit field to text in creating Table

I tried but can't use CASE WHEN in CREATE TABLE code to replace 1 and 0 with text. Can someone help me to solve it. Thank you so much :D

Upvotes: 0

Views: 101

Answers (1)

SchmitzIT
SchmitzIT

Reputation: 9552

You didn't specify which database platform you are on, but in SL Server, this is possible using the following:

CREATE TABLE Table1
(
  ID int 
  , name varchar(50)
  , YesNo bit
  , TrueFalse AS 
    (
      CASE WHEN YesNo = 1 Then 'True'
      ELSE 'False'
      END
    )      
);

See the fiddle here: http://sqlfiddle.com/#!3/35d18/3

Upvotes: 1

Related Questions