SSIS Derived Column Transformation if not blank

166 Views Asked by At

i have added a Derived Column task that adds " at the beginning of a field and " at the end of a field but i only want to apply it if the field is not null/not blank and contains characters

my expression is, this works and correctly ads "" to the field but i only want to apply if there is data in the field

"\"" + fieldname + "\""

but i cant work out how to only apply where field is not blank i tried something like this but is did not work

ISNULL([fieldname]) == FALSE ? "\"" + fieldname + "\"" : ""
2

There are 2 best solutions below

0
On

You can use the ISNULL this way

!ISNULL([fieldname]) ? "\"" + fieldname + "\"" : ""
0
On

you need both tests.

!ISNULL([fieldname]) && length(fieldname)>0 ? "\"" + fieldname + "\"" : ""

or a nested IF

!ISNULL([fieldname]) ?
     length(fieldname)>0 ? "\"" + fieldname + "\"" : ""
     : ""