0

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 + "\"" : ""
sql2015
  • 591
  • 3
  • 13
  • 34

2 Answers2

0

You can use the ISNULL this way

!ISNULL([fieldname]) ? "\"" + fieldname + "\"" : ""
Arun Palanisamy
  • 5,281
  • 6
  • 28
  • 53
0

you need both tests.

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

or a nested IF

!ISNULL([fieldname]) ?
     length(fieldname)>0 ? "\"" + fieldname + "\"" : ""
     : ""
KeithL
  • 5,348
  • 3
  • 19
  • 25