Solved

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

Posted on 2007-03-30
4
680 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

Independent Software Vendors: 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

In this article we will learn how to fix  “Cannot install SQL Server 2014 Service Pack 2: Unable to install windows installer msi file” error ?
What if you have to shut down the entire Citrix infrastructure for hardware maintenance, software upgrades or "the unknown"? I developed this plan for "the unknown" and hope that it helps you as well. This article explains how to properly shut down …
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.
Viewers will learn how to use the INSERT statement to insert data into their tables. It will also introduce the NULL statement, to show them what happens when no value is giving for any given column.

626 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