Derived Column Transformation not filtering as expected in SSIS 2008 Data Flow

  • Hi All,

    I have the following Expression working on a Derived Column in an SSIS Data Flow Transformation

    [Date_Start] == " 0 0- 0- 0" ? NULL(DT_WSTR,10) : SUBSTRING([Date_Start],5,4) + "-" + SUBSTRING([Date_Start],3,2) + "-" + SUBSTRING([Date_Start],1,2)

    However

    0 0- 0- 0

    values are not being replaced with NULLs by this expression.

    I have been trying to resolve this for the best part of a day so at this point any suggestions/advice would be appreciated...Thanks

  • In your expression, there is a space at the start of the string. Is that how your data looks?

    John

  • Hi John,

    I have tried with and without spaces at the start but made no difference

  • The current string in the expression is

    "0 0- 0- 0"

  • Hi All,

    I have the following Expression working on a Derived Column in an SSIS Data Flow Transformation

    [Date_Start] == " 0 0- 0- 0" ? NULL(DT_WSTR,10) : SUBSTRING([Date_Start],5,4) + "-" + SUBSTRING([Date_Start],3,2) + "-" + SUBSTRING([Date_Start],1,2)

    However

    0 0- 0- 0

    values are not being replaced with NULLs by this expression.

    I have been trying to resolve this for the best part of a day so at this point any suggestions/advice would be appreciated...Thanks

    OK,

    I have investigated this further . THe issue is not with the string

    " 0 0- 0- 0" as I said previously.

    The string I am trying to filter out is "0 0 0 0"

    what is outputted is not NULL for this value but "0 0- 0- 0"

    The attachment may help with this...

    I have tried applying a number of expresions to this column

    examples below

    [MSTUB-xInt_Only-Rev-Dt] == "00000000" || [MSTUB-xInt_Only-Rev-Dt] == "0 0 0 0" || [MSTUB-xInt_Only-Rev-Dt] == "0 0- 0- 0" ? NULL(DT_WSTR,10) : SUBSTRING([MSTUB-xInt_Only-Rev-Dt],5,4) + "-" + SUBSTRING([MSTUB-xInt_Only-Rev-Dt],3,2) + "-" + SUBSTRING([MSTUB-xInt_Only-Rev-Dt],1,2)

    [MSTUB-xInt_Only-Rev-Dt] == "0" + " " + "0" + " " + "0" + " " + "0" ? NULL(DT_WSTR,10) : SUBSTRING([MSTUB-xInt_Only-Rev-Dt],5,4) + "-" + SUBSTRING([MSTUB-xInt_Only-Rev-Dt],3,2) + "-" + SUBSTRING([MSTUB-xInt_Only-Rev-Dt],1,2)

    There seems to be an issue recognizing the spaces between the 0s ?

  • Not all spaces are created equal. Maybe they're tabs or something else that could look like a space. There's a function (ASCII or something like that) that will return the ASCII value for a given character. It may be worth using that to check that the character you're checking for is the same as the ones in your string.

    John

  • Hi,

    using TRIM solves the issue

    TRIM([MSTUB-xInt_Only-Rev-Dt]) == "0 0 0 0" ? NULL(DT_WSTR,10) : SUBSTRING([MSTUB-xInt_Only-Rev-Dt],5,4) + "-" + SUBSTRING([MSTUB-xInt_Only-Rev-Dt],3,2) + "-" + SUBSTRING([MSTUB-xInt_Only-Rev-Dt],1,2)

Viewing 7 posts - 1 through 6 (of 6 total)

You must be logged in to reply to this topic. Login to reply