How to prevent SSIS from writing column names to the flat file output?
16,040
The best way that I've found to accomplish this is the following:
- I create a test output flat file. I populate the .txt file with the result set from the SQL query that will be used in the package. Make sure that the first row of the .txt file contains the column header names.
- Create a Flat File Connection. Point it to the text output flat file. Check the "Column names in the first data row" box. This will make sure that the actual column header names will be used/shown, instead of "Column 0", "Column 1", etc. Click "OK" to close the Flat File Connection Manager.
- Edit the Flat File Destination item to make sure that the actual column header names are picked up and that the fields are mapped properly between your query and the output columns of your Flat File Connection. Click "OK".
- Highlight the Flat File Connection and press "F4" to open the "Properties" window. There, change the "ColumnNamesInFirstDataRow" to "False".
Now your output flat file will contain data only...no column header row. Yet you can still go to the Flat File Destination item and see the actual column header names being used there.
Related videos on Youtube
Author by
343
Updated on August 30, 2022Comments
-
343 over 1 year
I am getting the output in flat file as shown below.
How do I avoid column names from being written to the flat file output?
-
SebTHU about 8 yearsGood answer, but I'd like to emphasise your point 4: you MUST change the "ColumnNamesInFirstDataRow" to False in the "Properties" window, NOT by double-clicking the connection manager and going into the Editor. If you do the latter, SSIS "helpfully" decides that all your columns are going to be called Column1, Column2 etc and trashes all your mappings
-
Melinda over 6 yearsThanks so much. This was very helpful since I had SPACE() columns defined.