Quantcast
Channel: SQL Server Integration Services forum
Viewing all articles
Browse latest Browse all 24688

Conditional Concatenation in Derived Column

$
0
0

Hi,

for example i have 4 columns a, b, c and d

if a is null or blank than i want to get this value b-c-d

if b is null or blank than i want to get this value a-c-d

if c is null or blank than i want to get this value a-b-d

if d is null or blank than i want ot get this value a-b-c

if all columns have values it will be a-b-c-d.

(DT_STR,100,1252)((ISNULL(a) || LEN(a) == 0 ? "" : a) + (DT_STR,50,1252)(ISNULL(b) || LEN(b) == 0 ? "" : "-" + b) + (DT_STR,10,1252)(ISNULL(c) || LEN(c) == 0 ? "" : "-" + c) + (DT_STR,10,1252)(ISNULL(d) || LEN(d) == 0 ? "" : "-" + d))

in this expression i get some time -b-c-d if a is null i do not want - in the begining or if d is null it comes a-b-c- similarly i do not want - in the end

the values should be  b-c-d and a-b-c

Thanks

MH


MH


Viewing all articles
Browse latest Browse all 24688

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>