Still celebrating National IT Professionals Day with 3 months of free Premium Membership. Use Code ITDAY17

x
?
Solved

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

Posted on 2007-03-30
4
Medium Priority
?
682 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 500 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

New feature and membership benefit!

New feature! Upgrade and increase expert visibility of your issues with Priority Questions.

Question has a verified solution.

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

Recently we ran in to an issue while running some SQL jobs where we were trying to process the cubes.  We got an error saying failure stating 'NT SERVICE\SQLSERVERAGENT does not have access to Analysis Services. So this is a way to automate that wit…
Ready to get certified? Check out some courses that help you prepare for third-party exams.
Via a live example combined with referencing Books Online, show some of the information that can be extracted from the Catalog Views in SQL Server.
Using examples as well as descriptions, and references to Books Online, show the different Recovery Models available in SQL Server and explain, as well as show how full, differential and transaction log backups are performed

704 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