Solved

Convert 1/0 (bit) into True/False or Yes/No within query?

Posted on 2003-12-02
2
745 Views
Last Modified: 2010-08-05
Hi everyone-

Is there a way to convert the output of a bit (0/1) into True/False or Yes/No within a query?

I am calling a stored procedure that sends an email (with query results), and I just relized that one of the fields is a Bit, so it comes out 1 or 0.

I would like it to return something easier for a "common user" to understand, like True/False, or Yes/No.


*********************************
(Inventory..Inventory.discontinued is set to type Bit)

CREATE PROCEDURE [dbo].[sp_reorderInventorySendMail]
...
...
...
set @sqlQuery = "SELECT 'Discontinued?: ', Inventory..Inventory.discontinued FROM Inventory..Inventory WHERE Inventory..Inventory.id = " + convert(varchar(5), @itemId)

EXEC master..xp_sendmail
      @recipients = @inventoryManagerEmail,
      @copy_recipients = '',
      @subject = 'Inventory: Inventory Reorder Requested',
      @message = 'Inventory detected an item below inventory level.  The following information was returned:',
      @query = @sqlQuery,
      @no_header = true
GO
*********************************
0
Comment
Question by:pillbug22
[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 Comments
 
LVL 14

Accepted Solution

by:
adwiseman earned 100 total points
ID: 9861018
Use a case statement

Select CASE <field> WHEN 0 then 'False' ELSE 'True' END as Myfield

set @sqlQuery = "SELECT 'Discontinued?: ', CASE Inventory..Inventory.discontinued WHEN 0 then 'False' ELSE 'True' END as discontinued FROM Inventory..Inventory WHERE Inventory..Inventory.id = " + convert(varchar(5), @itemId)
0
 
LVL 6

Author Comment

by:pillbug22
ID: 9861081
Ah...that'll do it - thanks!
0

Featured Post

Comparison of Amazon Drive, Google Drive, OneDrive

What is Best for Backup: Amazon Drive, Google Drive or MS OneDrive? In this free whitepaper we look at their performance, pricing, and platform availability to help you decide which cloud drive is right for your situation. Download and read the results of our testing for free!

Question has a verified solution.

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

Why is this different from all of the other step by step guides?  Because I make a living as a DBA and not as a writer and I lived through this experience. Defining the name: When I talk to people they say different names on this subject stuff l…
International Data Corporation (IDC) prognosticates that before the current the year gets over disbursing on IT framework products to be sent in cloud environs will be $37.1B.
Familiarize people with the process of retrieving data from SQL Server using an Access pass-thru query. Microsoft Access is a very powerful client/server development tool. One of the ways that you can retrieve data from a SQL Server is by using a pa…
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.

689 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