?
Solved

SQL 2005 SSIS Include hearer and footer rows in Data Extract

Posted on 2009-07-14
5
Medium Priority
?
426 Views
Last Modified: 2013-11-10
I've been tasked with creating a merchandiser product extract for submission to Linkshare. I've extracted all the product information into a new table in SQL and using SSIS i've exported the table to a CSV file. However that's where I come unstuck.

The requirements also state that I need to do the following:
1. Add a header row to the CSV file in the format: HDR | Merchant id | Company Name | Time Stamp
2. Add a footer row below the product information in the format: TRL | product row count
3.Finally the resultant file name needs to include the date in the format filename_20091407 ie. yyyyddmm

Anyone?

0
Comment
Question by:Christie_M
[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 Comments
 
LVL 75

Expert Comment

by:Anthony Perkins
ID: 24851900
1.  If the header delimiter is the same as detail rows, then all you need to do is include the column names in the first row.
2. This can sometimes be accomplished by using a UNION statement with the same number/type of columns as the rest of the data.  Alternatively you will have to open the file and write the results at the end.
3. You can change this programatically within the SSIS package.
0
 

Author Comment

by:Christie_M
ID: 24852061
Both the header and the footer are different formats from the product data itself. So there would be no way to join tables or populate the first row. Any other ideas.

3. How do I porgram this in the SSIS package?
0
 
LVL 22

Accepted Solution

by:
PedroCGD earned 2000 total points
ID: 24867904
I created a example package with the solution at:
http://www.experts-exchange.com/Microsoft/Development/MS-SQL-Server/SQL-Server-2005/Q_24571933.html

Helped?
Regards,
Pedro
0

Featured Post

Get proactive database performance tuning online

At Percona’s web store you can order full Percona Database Performance Audit in minutes. Find out the health of your database, and how to improve it. Pay online with a credit card. Improve your database performance now!

Question has a verified solution.

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

JSON is being used more and more, besides XML, and you surely wanted to parse the data out into SQL instead of doing it in some Javascript. The below function in SQL Server can do the job for you, returning a quick table with the parsed data.
It is possible to export the data of a SQL Table in SSMS and generate INSERT statements. It's neatly tucked away in the generate scripts option of a database.
Via a live example, show how to extract insert data into a SQL Server database table using the Import/Export option and Bulk Insert.
This videos aims to give the viewer a basic demonstration of how a user can query current session information by using the SYS_CONTEXT function
Suggested Courses

801 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