Solved

SSIS Package - exporting text file - Visual Studio

Posted on 2014-01-16
7
301 Views
Last Modified: 2016-02-10
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
Comment
Question by:robthomas09
  • 5
7 Comments
 
LVL 16

Expert Comment

by:Surendra Nath
ID: 39786928
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
 

Author Comment

by:robthomas09
ID: 39787335
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
 

Author Comment

by:robthomas09
ID: 39790263
No luck any other ideas?
0
How to run any project with ease

Manage projects of all sizes how you want. Great for personal to-do lists, project milestones, team priorities and launch plans.
- Combine task lists, docs, spreadsheets, and chat in one
- View and edit from mobile/offline
- Cut down on emails

 

Author Comment

by:robthomas09
ID: 39791740
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
 

Accepted Solution

by:
robthomas09 earned 0 total points
ID: 39794799
Poor follow up
0
 

Author Closing Comment

by:robthomas09
ID: 39845106
paid someone to fix this for me, with .NET skills
0

Featured Post

What Security Threats Are You Missing?

Enhance your security with threat intelligence from the web. Get trending threat insights on hackers, exploits, and suspicious IP addresses delivered to your inbox with our free Cyber Daily.

Join & Write a Comment

Here's a requirements document template for an integration project (also known as Extract-Transform-Load or ETL) based on my development experience as an SQL Server Information Services (SSIS) developer over the years.
International Data Corporation (IDC) prognosticates that before the current the year gets over disbursing on IT framework products to be sent in cloud environs will be $37.1B.
Via a live example, show how to extract insert data into a SQL Server database table using the Import/Export option and Bulk Insert.
Viewers will learn how the fundamental information of how to create a table.

746 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

13 Experts available now in Live!

Get 1:1 Help Now