Solved

SSIS Package - exporting text file - Visual Studio

Posted on 2014-01-16
7
309 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
Simplifying Server Workload Migrations

This use case outlines the migration challenges that organizations face and how the Acronis AnyData Engine supports physical-to-physical (P2P), physical-to-virtual (P2V), virtual to physical (V2P), and cross-virtual (V2V) migration scenarios to address these challenges.

 

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

Optimizing Cloud Backup for Low Bandwidth

With cloud storage prices going down a growing number of SMBs start to use it for backup storage. Unfortunately, business data volume rarely fits the average Internet speed. This article provides an overview of main Internet speed challenges and reveals backup best practices.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
Developing a front end to SPLUNK 1 50
MSSQL join different row from other table 14 65
Using this function 4 38
SQL Select - identify record discrepancies 1 29
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.
The Delta outage: 650 cancelled flights, more than 1200 delayed flights, thousands of frustrated customers, tens of millions of dollars in damages – plus untold reputational damage to one of the world’s most trusted airlines. All due to a catastroph…
Via a live example combined with referencing Books Online, show some of the information that can be extracted from the Catalog Views in SQL Server.
Via a live example, show how to backup a database, simulate a failure backup the tail of the database transaction log and perform the restore.

679 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