'How to add column names to the flat files without column headers using SSIS.
I have multiple flat files containing 126 columns , but each of them is without column names. How should i add column names to these files using SSIS. These files are needed to be imported using SSIS so that i can perform transformation on these files.
Solution 1:[1]
Do you want to create a new file which has column names or just assign field names to the columns for use in the rest of the package?
Whichever way, if the input file does not contain column names then set them up as follows…
- Create a dataflow task and in the dataflow task create a flat file source.
- Configure the flat file source and create a new Flat File Connection Manager
- Browse to the input file you want and un-tick the Column Names In First Row
- Select Advanced and change all of the default names (Coulmn 0, Coulmn 1 etc) into the field names (and types) you want.
- Click OK
If you need to create a new file that has the column names in it, just create a flat file destination and this time have the Column Names In First Row turned on, wire it up to the input you created and save it to a new file
Solution 2:[2]
One way to do this (maybe not the quickest way) is by using the Advanced Editor.
Right click on the Excel Source component and select
Show advanced editor.In the new window, you need to go to the
Input and Output Properties. You should have this by now:
Click on a column under
Output Columns(F1,F2,...)In Common properties, edit the Name to what you want.
I added a derived column component as my next step and this is what I see under the aviable columns:
As you can see, F1 (which I edited in step 2) has a new column name now.
Edit: I somehow assumed you needed this for Excel. Anyways, I hope it helps.
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
| Solution | Source |
|---|---|
| Solution 1 | User42 |
| Solution 2 |

