Solved

Easy SQL: Return 'Demo' or 'Live' - instead of True or Fals on bit field

Posted on 2007-03-30
4
676 Views
Last Modified: 2012-06-27
SQL Server 2000.

I have a bit field - that returns True of False (obviously) (eg SELECT mybitfield from mytable).

returns

True
False
True

How can I return, say, 'Demo' if true is returned - and 'Live' if false?

Thanks!...
0
Comment
Question by:jon100
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 2
  • 2
4 Comments
 
LVL 9

Expert Comment

by:auke_t
ID: 18822914
select
  case when mybitfield = 1 then 'Demo' else 'Live' end
from
  mytable
0
 

Author Comment

by:jon100
ID: 18823312
thanks.

one more quick thing - how can i get that to return a column heading?
0
 
LVL 9

Accepted Solution

by:
auke_t earned 125 total points
ID: 18823350
select
  case when mybitfield = 1 then 'Demo' else 'Live' end as MyColumnHeading
from
  mytable
0
 

Author Comment

by:jon100
ID: 18823930
excellent - thanks a lot
0

Featured Post

Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Title # Comments Views Activity
mssql 7 32
SQL Job Failed 6 31
DMV Script to find how many times statistics are utilized 2 30
SQL Server set parent recort in select with row number 8 29
Let's review the features of new SQL Server 2012 (Denali CTP3). It listed as below: PERCENT_RANK(): PERCENT_RANK() function will returns the percentage value of rank of the values among its group. PERCENT_RANK() function value always in be…
Ever needed a SQL 2008 Database replicated/mirrored/log shipped on another server but you can't take the downtime inflicted by initial snapshot or disconnect while T-logs are restored or mirror applied? You can use SQL Server Initialize from Backup…
Via a live example, show how to extract insert data into a SQL Server database table using the Import/Export option and Bulk Insert.
This videos aims to give the viewer a basic demonstration of how a user can query current session information by using the SYS_CONTEXT function

710 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question