How do I get SSIS Data Flow to put '0.00' in a flat file?

一曲冷凌霜 提交于 2019-12-01 03:37:56

Could you use a Derived Column to change the format of the value? Did you try that?

I was having the exact same issue, and soo's answer worked for me. I sent my data into a derived column transform (in the Data Flow Transform toolbox). I added the derived column as a new column of data type Unicode String ([DT_WSTR]), and used the following expression:

Price < 1 ? "0" + (DT_WSTR,6)Price : (DT_WSTR,6)Price

I hope that helps!

I used the advanced editor to change the column from double-precision float to decimal and then set the Scale to 2:

Since you are exporting to text file, just export data preformatted.

You can do it in the query or create a derived column, whatever you are more comfortable with.

I chose to make the column 15 characters wide. If you import into a system that expects numbers those zeros should be ignored...so why not just standardize the field length?

A simple solution in SQL is as follows:

    select 
    cast(0.00 as money) as col1
    ,cast(0.00 as numeric(18,2)) as col2 
    ,right('000000000000000' + cast( 0.00 as varchar(10)), 15) as col3
    go

 col1                  col2                 col3
 --------------------- -------------------- ---------------
                 .0000                  .00 000000000000.00

Simply replace '0.00' with your column name and don't forget to add the FROM table_name, etc..

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!