如何使用SSIS将列名添加到没有列标题的平面文件中。

时间:2016-10-19 13:24:18

标签: sql-server ssis transformation data-cleaning

我有多个包含126列的平面文件,但每个文件都没有列名。我应该如何使用SSIS向这些文件添加列名。需要使用SSIS导入这些文件,以便我可以对这些文件执行转换。

2 个答案:

答案 0 :(得分:0)

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…

  1. Create a dataflow task and in the dataflow task create a flat file source.
  2. Configure the flat file source and create a new Flat File Connection Manager
  3. Browse to the input file you want and un-tick the Column Names In First Row
  4. Select Advanced and change all of the default names (Coulmn 0, Coulmn 1 etc) into the field names (and types) you want.
  5. 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

答案 1 :(得分:0)

One way to do this (maybe not the quickest way) is by using the Advanced Editor.

  1. Right click on the Excel Source component and select Show advanced editor.

  2. In the new window, you need to go to the Input and Output Properties. You should have this by now:enter image description here

  3. Click on a column under Output Columns (F1,F2,...)

  4. 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:

enter image description here

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.

相关问题