You should add a Data Flow Task to your SSIS project. Inside the DFT go to other sources and select a Flat File source. When you define the connection you can specify that it skip the first 4 rows and import data from row 5. You should be able to test this by using the preview
SSIS Package to get flat file output with appended lines
Hi Team,
Please find the attached file in which format I need the output through SSIS package.
As of now through SQL procedure I am able to get the header and corresponding data but unable to append the other lines. Please let me know the way how top append the other lines in any way through SSIS.
1st Line : Test Financial Data.
2nd Line : <Blank>
3rd Line : the header names as mentioned (Coming from SQL procedure)
4th Line : ----------------------+--------------------------------+-----
Then the data will come from the table as mentioned ()(Coming from SQL procedure)
Then the no of rows.
SQL Server Integration Services
SQL Server | Other
2 answers
Sort by: Most helpful
-
-
ZoeHui-MSFT 41,491 Reputation points
2023-02-16T02:42:53.06+00:00 You may first use DFT to load the data from SQL procedure to txt file temporarily.
And then add Script Task to add the three lines with the C# code like below.
string filePath = "C:\\Users\\Administrator\\Desktop\\test.txt"; List<string> lines = new List<string>(); if (File.Exists(filePath)) { lines = File.ReadAllLines(filePath).ToList(); } lines.Insert(1, "-------------------------------------------"); string newContent="Test Financial Data."+Environment.NewLine+Environment.NewLine; File.WriteAllText(filePath, newContent + string.Join("\r",lines));
Regards,
Zoe Hui
If the answer is helpful, please click "Accept Answer" and upvote it.