locked
how to Add column header manually in SSIS flat file destination RRS feed

  • Question

  • From flat file source,I have to write the data in flat file destination after some transformation. My source file don't have column names. But i have to add column names in destination file. Please suggest a way to do that.
    Monday, March 6, 2017 10:07 AM

All replies

  • Hi,

    Enable the check box "Column names in the first data row" in your flatfile destination manager

    Monday, March 6, 2017 11:26 AM
  • Hi

    The way I used to do it (Have not done this since SQL 2008 so things might have changed) is

    1. Create a template file eg template.CSV, this template file would contain only 1 row which is the header.
    2. On each execution of the SSIS Package create a new copy of the template file giving it a name. (This will be the file setup in the file connection manager), I preferred doing this using the script component but I'm sure you can do it with the file system components as well.
    3. Setup the flat file destination to append new rows. 

    This will give you a new file with a header in each execution. 

    Note: make sure that the template file overwrites the file generated in the last execution.

    Monday, March 6, 2017 11:29 AM
  • Hi, Thanks for your answers. Since I am new to SSIS, could you please elaborate this with step by step? It will be really helpful to me.
    Monday, March 6, 2017 11:48 AM
  • Hi SQL MSBI,

    Another way is that you can try to create an another flat file which has the column header row, then using an Execute Process Task to combine the two flat files. Please refer to following steps:

    1.Sample Data.

    2. Using the Execute Process Task.

    The Arguments is : /C copy E:\SSIS\test\Header.txt + E:\SSIS\test\Content.txt E:\SSIS\test\Result.txt

    3. Execute the Task(package).

    Reference: create a header for flat file destination using ssis

    If you still have any questions, please feel free to ask.

    Best Regards,

    Pirlo Zhang


    MSDN Community Support
    Please remember to click "Mark as Answer" the responses that resolved your issue, and to click "Unmark as Answer" if not. This can be beneficial to other community members reading this thread. If you have any compliments or complaints to MSDN Support, feel free to contact MSDNFSF@microsoft.com.

    • Proposed as answer by Pirlo Zhang Sunday, March 12, 2017 5:16 PM
    Tuesday, March 7, 2017 6:21 AM
  • Hi SQL MSBI,

    If your issue is solved please mark the appropriate answer as Mark as answer. This will help other members to find a solution if they face the same issue.

    Thanks for your understanding and support.

    If you still have any questions, please feel free to ask.

    Best Regards,
    Pirlo Zhang


    MSDN Community Support
    Please remember to click "Mark as Answer" the responses that resolved your issue, and to click "Unmark as Answer" if not. This can be beneficial to other community members reading this thread. If you have any compliments or complaints to MSDN Support, feel free to contact MSDNFSF@microsoft.com.

    Wednesday, March 22, 2017 8:55 AM