How can I replace a value within a Sql Select which returns multiple rows?
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 开发者_JAVA技巧default values with display friendly values.
How can I replace the default values before returning from the stored procedure?
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'
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.
Couple other options for null...
ISNULL and COALESCE
精彩评论