Tuesday, April 21, 2015

Flat file of types fixed width and Ragged right problem, while exporting..?

I’m using the Import\Export wizard to export the top 5 lines from a MS Sql table into a fixed format (“ragged”) file. But I want the first record to contain the column names of the exported fields so I selected the “Column names in the first data row” option of the “Choose a Destination” box. When I run the Package I get:
>>>
· Information 0x402090dc: Data Flow Task: The processing of file "C:\barkingdog\ExportWithheader.txt" has started (SQL Server Import and Export Wizard)
· Error 0xc0202095: Data Flow Task: Failed to write out column name for column "CustomerID".
(SQL Server Import and Export Wizard)
Error 0xc004701a: Data Flow Task: component "Destination - ExportWithheader_txt" (49) failed the pre-execute phase and returned error code 0xC0202095.
(SQL Server Import and Export Wizard)
>>>
When I de-select the “Column names” option, the package works fine. Other than manually, how can I et the column names in output file?
 
 
 
 
Answer:
 
 
The problem here is that when you include column names in the first data row, then you might need to modify the column width (for a ragged right file). For example, if you have a column CustomerID which is of type DT_STR(5), it will fail trying to write "CustomerID" in that space, which takes 10 characters. Use the Edit Transform button on configure Flat File Destination page of the Import Export Wizard to adjust the length specified for each fixed width column.


hope that helps.

No comments:

Post a Comment