| Author |
Topic |
|
tpiazza55
Posting Yak Master
162 Posts |
Posted - 2007-01-08 : 08:43:33
|
| i have a case statement CASE when stuff then valueend as emailthere are several instances where i come up with 2 valuesis there a way to get these values distinctlynot email = value1 + "," + value2but actually get value1 and value2 so i can use them as output without parsing in the program? |
|
|
SwePeso
Patron Saint of Lost Yaks
30421 Posts |
|
|
tpiazza55
Posting Yak Master
162 Posts |
Posted - 2007-01-08 : 08:55:58
|
| no different one |
 |
|
|
SwePeso
Patron Saint of Lost Yaks
30421 Posts |
Posted - 2007-01-08 : 09:01:31
|
| SELECT CASE WHEN Value1 IS NULL THEN ISNULL(Value2, '')WHEN Value2 IS NULL THEN ISNULL(Value1, '')ELSE Value1 + ', ' + Value2ENDPeter LarssonHelsingborg, Sweden |
 |
|
|
X002548
Not Just a Number
15586 Posts |
|
|
SwePeso
Patron Saint of Lost Yaks
30421 Posts |
Posted - 2007-01-08 : 09:24:54
|
| What do you mean?Peter LarssonHelsingborg, Sweden |
 |
|
|
X002548
Not Just a Number
15586 Posts |
|
|
SwePeso
Patron Saint of Lost Yaks
30421 Posts |
Posted - 2007-01-08 : 09:54:30
|
| No, I meant with "No value".If you refer to NULL value, and both parameters are NULL, my first CASE will handle that.I wrote this way to make the output look nice, without unnecessary commas.Peter LarssonHelsingborg, Sweden |
 |
|
|
SwePeso
Patron Saint of Lost Yaks
30421 Posts |
Posted - 2007-01-08 : 10:02:06
|
| But you are right if one or both of the parameters are empty.SELECT CASE WHEN Value1 IS NULL OR Value1 = '' THEN ISNULL(Value2, '')WHEN Value2 IS NULL OR Value2 = '' THEN ISNULL(Value1, '')ELSE Value1 + ', ' + Value2ENDPeter LarssonHelsingborg, Sweden |
 |
|
|
tpiazza55
Posting Yak Master
162 Posts |
Posted - 2007-01-08 : 12:16:21
|
| thanks |
 |
|
|
|