Please start any new threads on our new site at https://forums.sqlteam.com. We've got lots of great SQL Server experts to answer whatever question you can come up with.

 All Forums
 SQL Server 2005 Forums
 SSIS and Import/Export (2005)
 Output results of a Stored Proc to CSV with SSIS?

Author  Topic 

theboyholty
Posting Yak Master

226 Posts

Posted - 2011-07-11 : 05:25:16
Its probably quite a simple one this but I'm fairly new to SSIS.

I need to run a stored procedure each morning and output the results into a csv file in a specific location.

I've set up a Execute SQL Task which successfully runs the SP, now I'm not sure what to do to get it to export the data to a csv file.

Any ideas?

---------------------------------------------------------------------------------
http://www.mannyroadend.co.uk The official unofficial website of Bury Football Club
http://www.hollowtreewebdesign.co.uk - a web design company in its infancy

sqldataguy
Starting Member

12 Posts

Posted - 2011-07-12 : 10:22:53
On the Control tab you already have an Execute SQL Task which runs the SP, a good start.

What I've done is set up my SP to use a table in SQL dedicated to this task, say SP_Output. First thing the SP does is delete all existing rows in that table, then gets the data and inserts the new day's results.

Now go to the Data Flow tab and add a OLE DB Source which will be the table SP_Output.

Then add a data flow destination, which in this case will be a Flat File Destination. Set up the Connection Manager so that the Connection String is the directory you want the file outputed to.

Finish up by by adding a Path to the Flat File Destination so that it gets it's data from the OLE DB Souce. Easiest if you use the same field names in SP_Output and text file, but you can do mapping if necessary
Go to Top of Page
   

- Advertisement -