Link to home
Start Free TrialLog in
Avatar of PJLewis2015
PJLewis2015

asked on

How to add a footer to a text file in SSIS (Visual Studio 2010)

How does my SSIS job append a footer to a text file that has just been written?
Avatar of Barry Cunney
Barry Cunney
Flag of Ireland image

Hi PLewis,
After your Dataflow task which creates the text file, add in a Script Task.
In this Script Task you can write C# code which opens the  text file and appends the necessary footer lines.
In C# you can use the StreamWriter object to achieve this.
Avatar of PJLewis2015
PJLewis2015

ASKER

Thanks for the quick response Barry.  Unfortunately, I barely remember my VB Script and have not used C#.

I am trying to append "EOF" to the flat file (customer requirement).  The number of records can be large.

Is there a way I could use T-SQL  to attach "EOF" as the last row in the result set?
ASKER CERTIFIED SOLUTION
Avatar of Barry Cunney
Barry Cunney
Flag of Ireland image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Thanks and it works.

FYI, I found a faster way:  

Let's say I use a simple SQL query:

      SELECT ID, NameF, NameL FROM Employee.

Then for giggles, I tried a UNION

      SELECT SSN, NameF, NameL FROM Employee
      UNION
      SELECT TOP 1 '' AS SSN, '' AS NameF, '' AS NameL FROM Employee
      ORDER BY SSN

It worked when I used the second SQL query above in the SSIS package!
SOLUTION
Avatar of Jim Horn
Jim Horn
Flag of United States of America image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
You aren't 'da man' - you're his big brother!

Thanks for your advice.