ssis data conversion from numeric to char

  • I need to convert a numeric dec(3,0) to char(3) so I can perform a lookup with this value.

    Not only do I need to convert, but also format so it includes the leading zero.

    The target value is char(3) but only the first 2 places are used.

    What Data Flow Transformation do I use?

    Example:

    numeric value "1" will become char value "01 "

    numeric value "31" will become char value "31 "

  • After your typecast, run it through a Derived Column transform, and use the following for your expression (bear with me, I don't have my editor open so this is freehand):

    (LEN(my_val) == 1) ? "0" + my_val : my_val

    This will prepend a zero to the column named my_val if the length of the item is 1.

    hth,

    Tim

Viewing 2 posts - 1 through 1 (of 1 total)

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