thenna thenna - 1 year ago 89
SQL Question

How to select BIT columns as TRUE

I have a table called TP_Roles.

This Table structure is:

Id PK, int, not null
Role_Name varchar(200), null
IsActive bit, null

How Do I insert bit value as True instead of 1 ?

Many thanks.

Answer Source

BIT values are 1/0 and they correspond to TRUE/FALSE accordingly.

By the comments I assume you want to view TRUE / FALSE when selecting this column, so you can simply use a CASE EXPRESSION for this:

SELECT <Column1>,<Column2>...,
       CASE WHEN IsActive = 1 THEN 'TRUE' ELSE 'FALSE' END as IsActive
FROM YourTable

If IsActive = 1 - display TRUE , else , display FALSE .

Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download