views:

42

answers:

3

I have a stored proc that is called from my asp.net page. The field "RecordUpdated" returns TRUE or FALSE. I need that column to return YES (if true) or NO (if false)

How would I do that?

SET @SQL = 'SELECT RecID, Vendor_Number, Vendor_Name, Invoice_Number, Item_Number, RecordAddDate, RecordUpdated FROM Vendor_Invoice_Log'
SET @SQL = @SQL + ' ORDER BY Item_Number, Vendor_Number
PRINT @SQL
+3  A: 

If all you are doing is trying to change TRUE to YES and FALSE to NO, you can do this:

select case 
  when recordupdated = true then 'YES' 
  when recordupdated = false then 'NO' 
end recordupdates ...

Of course your code doesn't actually execute, so I am uncertain why you showed lines 2 and 3.

MJB
+1  A: 

Sounds like a job for CASE()...

Arnshea
+1  A: 

In situations where you need to return one or the other of something when doing a SELECT, the

CASE
    WHEN true
    THEN YES
    WHEN false
    THEN NO
END AS RecordUpdated

is pretty useful.

badpanda