Reputation: 87
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
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