开发者

SSIS (DT_Decimal) to (DT_Str) removes trailing zeros for decimals

When converting from DT_Decimal to DT_Str, the derived column stips off decimals from my result.

ex.: -0.1250 returns -0.125 -2.0000 returns -2

Is there a way to keep the zeros to have a final string with always four decimals ?

Here is my derived column for the decimal value calculation:

(DT开发者_如何学Python_DECIMAL,4)ROUND((DT_Decimal,4)[Column 1] / (DT_DECIMAL,4)@[User::rate],2)

Here is my string expression to bring it to right aligned string with 11 characters:

RIGHT(REPLICATE(" ",11) + TRIM((DT_STR,11,1252)
(DT_DECIMAL,4)ROUND((DT_Decimal,4)[Column 1] / (DT_DECIMAL,4)@[User::rate],2)
),11)

I'm using SSIS 2008.

Thanks in advance. Francis


What about testing for posision of "." If greather than append "0000" and take the left part of the string. The length argument for the Left function should be the position of "." plus 4

If zero then append ".0000"

Please be carefull when using division. If you divide by zero you get an error. I normally divide by NULLIF(Rate, 0), and get NULL if I try to divide by zero.


An option:

(DT_DECIMAL, 4)ROUND(User::rate,4) - removes extra zeroes

(DT_NUMERIC,18,4)ROUND(User::rate,4) - keeps zeroes
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜