Solved

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

Posted on 2003-12-02
2
738 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
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

Microsoft Certification Exam 74-409

Veeam® is happy to provide the Microsoft community with a study guide prepared by MVP and MCT, Orin Thomas. This guide will take you through each of the exam objectives, helping you to prepare for and pass the examination.

Question has a verified solution.

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

Ever wondered why sometimes your SQL Server is slow or unresponsive with connections spiking up but by the time you go in, all is well? The following article will show you how to install and configure a SQL job that will send you email alerts includ…
I have a large data set and a SSIS package. How can I load this file in multi threading?
Familiarize people with the process of utilizing SQL Server functions from within Microsoft Access. Microsoft Access is a very powerful client/server development tool. One of the SQL Server objects that you can interact with from within Microsoft Ac…
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.

776 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