tags:

views:

43

answers:

3

I have a table that has default values in a few columns. When I run a stored procedure to select the data for display I want to replace the default values with display friendly values.

How can I replace the default values before returning from the stored procedure?

+3  A: 

I'm guessing you have default values such as null, or 0?

In your sprocs, can you do a Case statement on that column?

CASE WHEN [Column] is Null then 'N/A'
Jack Marchetti
That's what I was forgetting, thanks!
Nescio
Some good links on the CASE statement: http://www.devx.com/tips/Tip/15633http://www.4guysfromrolla.com/webtech/102704-1.shtml
TLiebe
+2  A: 

I'm at home, so I don't have examples, but you can do something like this...

select field1 as case
 field1 = 'val1' as 'This is the first value',
 field1 = 'val2' as 'This is the second value'
from table

and then the rest of the where, order or whatever else you need. In other words, look at the case statement and the syntax for that.

thursdaysgeek
Thanks! Jack was a little bit faster, but still +1 for the example.
Nescio
+1  A: 

Couple other options for null...

ISNULL and COALESCE

keithwarren7
OMG Ponies