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?

I believe you can use bcp tobulk export with a format file to meet your needs. SeeFormat Files for Importing or Exporting Data for a place to start.|||

if you use SQL 2005 export wizard or custom SSIS package try to select Ragged right format for flat file destination:

Format

Indicate whether to use delimited, fixed width, or ragged right formatting.

ValueDescription

Delimited

Columns are separated by a delimiter, specified on theColumns page.

Fixed width

Columns have a fixed width.

Ragged right

Ragged right files are those in which every column has a fixed width, except for the last column, which is delimited by the row delimiter.

|||thanks, that worked. How can I execute SSIS package in a stored procedure or in a batch file in Windows?|||You can run it as SQL Agent Job which has SSIS step and this is probably best way or you can run it as batch process from command prompt or from inside SQL procedure. To generate command you can use dtsrunui.exe program which will help you a lot.

No comments:

Post a Comment