Solved

SQL 2005 SSIS Add an unrelated header line to a text file

Posted on 2009-07-15
4
353 Views
Last Modified: 2013-11-10
I need to add an unreleated header line to the top of a text file I'm already extraciting using a SSIS package.

The extracted file needs to look like this:

HDR | MERCHANT REF | MERCHANT NAME | TIME STAMP
1321 | Cushions | CC1234/01| In Stock | £120.00 | Percentage Discount | 50 | etc.
1321 | Cushions | CC1234/01| In Stock | £120.00 | Percentage Discount | 50 | etc.
1321 | Cushions | CC1234/01| In Stock | £120.00 | Percentage Discount | 50 | etc.
1321 | Cushions | CC1234/01| In Stock | £120.00 | Percentage Discount | 50 | etc.
1321 | Cushions | CC1234/01| In Stock | £120.00 | Percentage Discount | 50 | etc.

The header row has a differnet number of columns and different data type from the rest of the extract. So I can't just populate the first row of the source table. So:

1. How do I ammend the SSIS package to write a custom header row to the text file before the rest of the data is written?
2. What expression will give me a time stamp in the final column of the header row?
0
Comment
Question by:Christie_M
  • 3
4 Comments
 
LVL 22

Expert Comment

by:PedroCGD
ID: 24858782
You can add the header after creating the file, correct?
You can use a script task to add an extra row in the header!
Regards,
Pedro
0
 

Author Comment

by:Christie_M
ID: 24858832
Thanks Pedro, there is nothing to stop me adding the header retrospectively. I just don't know how to do that. Do you have an example script that I could use?
0
 
LVL 22

Accepted Solution

by:
PedroCGD earned 500 total points
ID: 24861404
Take a look to the package I made here and try to customize!
Regards,
Pedro
0
 
LVL 22

Assisted Solution

by:PedroCGD
PedroCGD earned 500 total points
ID: 24862127
0

Featured Post

NAS Cloud Backup Strategies

This article explains backup scenarios when using network storage. We review the so-called “3-2-1 strategy” and summarize the methods you can use to send NAS data to the cloud

Question has a verified solution.

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

Suggested Solutions

This article explains how to reset the password of the sa account on a Microsoft SQL Server.  The steps in this article work in SQL 2005, 2008, 2008 R2, 2012, 2014 and 2016.
This article shows gives you an overview on SQL Server 2016 row level security. You will also get to know the usages of row-level-security and how it works
This video shows how to set up a shell script to accept a positional parameter when called, pass that to a SQL script, accept the output from the statement back and then manipulate it in the Shell.
Using examples as well as descriptions, and references to Books Online, show the different Recovery Models available in SQL Server and explain, as well as show how full, differential and transaction log backups are performed

809 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