Solved

SSIS Package - exporting text file - Visual Studio

Posted on 2014-01-16
7
317 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 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
Will your db performance match your db growth?

In Percona’s white paper “Performance at Scale: Keeping Your Database on Its Toes,” we take a high-level approach to what you need to think about when planning for database scalability.

 

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

Get 15 Days FREE Full-Featured Trial

Benefit from a mission critical IT monitoring with Monitis Premium or get it FREE for your entry level monitoring needs.
-Over 200,000 users
-More than 300,000 websites monitored
-Used in 197 countries
-Recommended by 98% of users

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Why is this different from all of the other step by step guides?  Because I make a living as a DBA and not as a writer and I lived through this experience. Defining the name: When I talk to people they say different names on this subject stuff l…
A phishing scam that claims a recipient’s credit card details have been “suspended” is the latest trend in spoof emails.
This video shows, step by step, how to configure Oracle Heterogeneous Services via the Generic Gateway Agent in order to make a connection from an Oracle session and access a remote SQL Server database table.
Using examples as well as descriptions, and references to Books Online, show the documentation available for date manipulation functions and by using a select few of these functions, show how date based data can be manipulated with these functions.

632 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