SSIS : Read flat file header and load data into table.

kkran 831 Reputation points
2023-06-23T22:29:19.3433333+00:00

Hi All - I have a package the reads the csv file and loads the data into the SQL table. But in SSIS i have checked in option of 'Headerrowstoskip' =1. My table is static and below is my table structure. Earlier, the requirement was not to read the header and flow the data into table with the below structure.

Here is the header of the file:
User's image

The column3 will change depending on the month we receive the file. As this June its starting with 6/1/2023.

Now the requirement has changed, i have to read the header i guess, the user wants to create additional column 'fordate' in the table and insert the header name of column3. In the above file example, the header name of column3 is 6/1/2023 so in the table the new column should have the value of '2023-06-01'.

Could you please help with this ?

       [Part_Number]
      ,[Region]
      ,[Month1]
      ,[Month2]
      ,[Month3]
      ,[Month4]
      ,[Month5]
      ,[Month6]
      ,[Month7]
      ,[Month8]
      ,[Month9]
      ,[Month10]
SQL Server Integration Services
SQL Server | Other
{count} votes

Answer accepted by question author
  1. ZoeHui-MSFT 41,536 Reputation points
    2023-06-27T02:29:17.3133333+00:00

    Hi @kkran,

    It is hard to meet your requirement via SSIS or TSQL code if you want to do this automatically.

    The easiest way is modifying the data in csv file and then load data to table.

    Regards,

    Zoe Hui


    If the answer is helpful, please click "Accept Answer" and upvote it.


0 additional answers

Sort by: Most helpful

Your answer

Answers can be marked as 'Accepted' by the question author and 'Recommended' by moderators, which helps users know the answer solved the author's problem.