Wednesday, March 7, 2012

Export to Fixed width text file

Export to Fixed width text file

I am trying to export a table to a fixed lenght text file, there is only flat file option and that does not put LF/CR at the end of row, is there any solution?

Ragged right works for me. You can used a derived column to pad your string with spaces if necessary.|||Can you be more specific about what the problem is? I didn't have any trouble setting up a fixed width flat file destination with a LF/CR row delimiter. Add a flat file destination, open it and click New to create a new connection manager, select "Fixed width with row delimiters", give it a file name, switch to Advanced and select the "Row delimiter column" to change the ColumnDelimiter to {LF}{CR} if desired.
|||Row delimiter is not elabled in my environment. What would the problem be?|||It isn't there, or it is but its disabled? Can't think of why either would be the case.

If the above doesn't work for some reason, you can create the same configuration as follows. Open the flat file connection manager (or create a new one). On the General tab, select Ragged Right as the format. For starters, let's not not check "column names in the first data row". Switch to the Advanced tab and add your columns with appropriate DataTypes and OutputColumnWidths. The ColumnType should automatically be Fixed Width for each column but the last one. The last one will be Delimited. Create a dummy column to be your last one. Make its DataType String, OutputColumnWidth 0, and ColumnDelimited to be whatever you want for the row delimiter (you had previously said you wanted {LF}{CR}).
|||

Part of the confusion here may be that you have to pick the Ragged Right option for the flat file connector, not the Fixed Width option. It seems a little counter-intuitive.

Interestingly, if you create your connection manager as Jay suggested originally (by adding the flat file destination, then choosing the New... button beside the connection manager drop-down, the resulting dialog asks if you want a fixed width with row delimiters, then creates a ragged right as Jay's described above.

No comments:

Post a Comment