Go Premium for a chance to win a PS4. Enter to Win

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 327
  • Last Modified:

SSIS Package - exporting text file - Visual Studio

Hello experts,

I have Microsoft Visual Studio 2012 with SSIS tools installed, and I currently have a package that is harvesting data from a few tables in the database via SQL script, but ultimately compiling and outputting in CSV format to a text file with headers.

Looks something like this in the output:

person_id            file_id               location_id
12345                  NG1234           1234567890
12345                  NG1235           1234567891
12346                  NG1236           1234567892
12346                  NG1237           1234567893

That works just fine but I recently received a request to have a 1-time bit of text at the top before the CSV file data floods in, mostly header information.  I would like to find a way to have the file out put be:

user:testuser
password:uf43ufn4u
api_id:34593434
text:Hello #field1#, your account balance is now #field2# as of 12:00AM today.
delimiter:|
person_id            file_id               location_id
12345                  NG1234           1234567890
12345                  NG1235           1234567891
12346                  NG1236           1234567892
12346                  NG1237           1234567893

The chunk of text at the top, right before the CSV person_id text starts, would be static and never changing believe it or not.

Thoughts?

Thanks!
0
robthomas09
Asked:
robthomas09
  • 5
1 Solution
 
Surendra NathCommented:
There are many ways to do this

1) after the data flow task at the end of your package, put a script compoenent.
And in the script by using the .NET runtime open the file and add the text to the start of it -- pretty easy task -- but not appealing to tech geeks.
0
 
robthomas09Author Commented:
Thanks for the reply!

Not being the strongest at .NET, I will do some research and give that a try for sure.  I did see that you mentioned "There are many ways to do this" - any chance on elaborating on a few of the others in case I might be stronger-suited in in one of those manners?

Thanks again!
0
 
robthomas09Author Commented:
No luck any other ideas?
0
Veeam Task Manager for Hyper-V

Task Manager for Hyper-V provides critical information that allows you to monitor Hyper-V performance by displaying real-time views of CPU and memory at the individual VM-level, so you can quickly identify which VMs are using host resources.

 
robthomas09Author Commented:
Something like:


    public override void PostExecute()
    {
        base.PostExecute();
        System.IO.StreamWriter tw
        = System.IO.File.AppendText(@"C:\Test.txt");

            tw.WriteLine("Text at the top of the file");
       
        base.ProcessInput(InputID, Buffer);
        tw.Close();
    }

    public override void CreateNewOutputRows()
    {

    }

}
0
 
robthomas09Author Commented:
Poor follow up
0
 
robthomas09Author Commented:
paid someone to fix this for me, with .NET skills
0

Featured Post

NEW Veeam Backup for Microsoft Office 365 1.5

With Office 365, it’s your data and your responsibility to protect it. NEW Veeam Backup for Microsoft Office 365 eliminates the risk of losing access to your Office 365 data.

  • 5
Tackle projects and never again get stuck behind a technical roadblock.
Join Now