locked
Need help with expression RRS feed

  • Question

  • Hi,

    I need to replace a field that might contain a certain character with another should the value occur.
    To explain

    If i get a hash # in the field, then I need to replace the whole field with a 0 since its a numeric field

    I'm just a bit of a noob still with expressions

    Regards
    Friday, September 28, 2007 2:52 PM

Answers



  • Try this one:

    FINDSTRING((DT_WSTR,5)Col1,"#",1) > 0 ? 0 : (DT_I4)Col1

    Notice that casting to DT_WSTR is necessary as FINDSTRING only works with that data type; if COL1 is already DT_WSTR; then you dont need to cast it.
    Friday, September 28, 2007 3:41 PM

All replies



  • Try this one:

    FINDSTRING((DT_WSTR,5)Col1,"#",1) > 0 ? 0 : (DT_I4)Col1

    Notice that casting to DT_WSTR is necessary as FINDSTRING only works with that data type; if COL1 is already DT_WSTR; then you dont need to cast it.
    Friday, September 28, 2007 3:41 PM
  • Thanks Rafael,

    It works perfectly!

    Keep well
    Michael
    Saturday, September 29, 2007 6:29 PM