Solved

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

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

How to improve team productivity

Quip adds documents, spreadsheets, and tasklists to your Slack experience
- Elevate ideas to Quip docs
- Share Quip docs in Slack
- Get notified of changes to your docs
- Available on iOS/Android/Desktop/Web
- Online/Offline

Join & Write a Comment

I wrote this interesting script that really help me find jobs or procedures when working in a huge environment. I could I have written it as a Procedure but then I would have to have it on each machine or have a link to a server-related search that …
When you hear the word proxy, you may become apprehensive. This article will help you to understand Proxy and when it is useful. Let's talk Proxy for SQL Server. (Not in terms of Internet access.) Typically, you'll run into this type of problem w…
Via a live example, show how to backup a database, simulate a failure backup the tail of the database transaction log and perform the restore.
Viewers will learn how to use the UPDATE and DELETE statements to change or remove existing data from their tables. Make a table: Update a specific column given a specific row using the UPDATE statement: Remove a set of values using the DELETE s…

707 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

Need Help in Real-Time?

Connect with top rated Experts

13 Experts available now in Live!

Get 1:1 Help Now