Solved

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

Posted on 2003-12-02
2
734 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
Comment Utility
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
Comment Utility
Ah...that'll do it - thanks!
0

Featured Post

Top 6 Sources for Identifying Threat Actor TTPs

Understanding your enemy is essential. These six sources will help you identify the most popular threat actor tactics, techniques, and procedures (TTPs).

Join & Write a Comment

In this article—a derivative of my DaytaBase.org blog post (http://daytabase.org/2011/06/18/what-week-is-it/)—I will explore a few different perspectives on which week today's date falls within using Microsoft SQL Server. First, to frame this stu…
Having an SQL database can be a big investment for a small company. Hardware, setup and of course, the price of software all add up to a big bill that some companies may not be able to absorb.  Luckily, there is a free version SQL Express, but does …
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 extract insert data into a SQL Server database table using the Import/Export option and Bulk Insert.

743 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

16 Experts available now in Live!

Get 1:1 Help Now