by jim
May 11, 2010 2:56 PM
Do you need to get your SSIS output to convert numbers to strings, with a specific number of decimal places? I needed my derived columns to be blank if the number is zero, or show as money (2 decimals places) if not.
Converting to decimal has no effect; the output does not show a fixed number of digits after the zero.
Amount < 0 ? (DT_WSTR,20)(DT_DECIMAL,2)(0 - Amount) : ""
The trick is to convert to DT_NUMERIC, instead. The conversion to DT_WSTR will then include zeros to pad to the desired scale. (Scale is the number of decimal places, and precision is the total number of digits.)
Amount > 0 ? (DT_WSTR,20)(DT_NUMERIC,15,2)(Amount) : ""