Click here to monitor SSC
SQLServerCentral is supported by Red Gate Software Ltd.
 
Log in  ::  Register  ::  Not logged in
 
 
 
        
Home       Members    Calendar    Who's On


Add to briefcase

Run Multiple SQL Queries Expand / Collapse
Author
Message
Posted Monday, November 26, 2012 10:36 AM
Forum Newbie

Forum NewbieForum NewbieForum NewbieForum NewbieForum NewbieForum NewbieForum NewbieForum Newbie

Group: General Forum Members
Last Login: Monday, January 21, 2013 1:42 PM
Points: 8, Visits: 20
I am new to SSIS so need help with some issues. Creating a task which involves running multiple sql queries and then exporting its result to an excel file. I checked online and found that "Execute SQL task" has the capability of running multiple sql queries but I am not sure how to get its output in an excel file OR how to attach it to a data flow task.

Please help.

Thanks
Post #1388722
Posted Monday, November 26, 2012 10:50 AM
UDP Broadcaster

UDP BroadcasterUDP BroadcasterUDP BroadcasterUDP BroadcasterUDP BroadcasterUDP BroadcasterUDP BroadcasterUDP Broadcaster

Group: General Forum Members
Last Login: Yesterday @ 9:55 AM
Points: 1,485, Visits: 1,036
Execute sql tasks do not allow you to export data to a file.

As stated your running multiple queries in your execute sql task.
You can select your results and store them in a variable with a type of Object.
and use a script task to export the file, but this is technical.

Or you can Create a "Staging" Table in your sql server source. Insert all the data you want to export to this staging table, and then you can use that table as the source for your export. This is a common method for exporting data. Very simple, and the staging table serves as a handy resource for you to validate data and perfrom as many transformations on the data in native sql which is usually faster than doing them in SSIS.
I usually do a simple select from the source database in a dataflow container, and insert the Target data into a staging table in my ETL database, do any masaging I need with sql tasks, and then export the data in a different dataflow container.


Post #1388728
Posted Monday, November 26, 2012 11:40 PM


SSChampion

SSChampionSSChampionSSChampionSSChampionSSChampionSSChampionSSChampionSSChampionSSChampionSSChampion

Group: General Forum Members
Last Login: Yesterday @ 11:42 AM
Points: 13,295, Visits: 11,086
You can have multiple OLE DB sources in your dataflow. Each of them executes one SQL query. You can append to resultsets to each other using the UNION ALL component if each resultset has the same layout. If they have different layouts you'd need different dataflows for each SQL query.



How to post forum questions.
Need an answer? No, you need a question.
What’s the deal with Excel & SSIS?

Member of LinkedIn. My blog at LessThanDot.

MCSA SQL Server 2012 - MCSE Business Intelligence
Post #1388970
Posted Tuesday, November 27, 2012 2:53 PM
Forum Newbie

Forum NewbieForum NewbieForum NewbieForum NewbieForum NewbieForum NewbieForum NewbieForum Newbie

Group: General Forum Members
Last Login: Monday, January 21, 2013 1:42 PM
Points: 8, Visits: 20
Thank you so much for the suggestions :)

I was able to complete the task.
Post #1389424
« Prev Topic | Next Topic »

Add to briefcase

Permissions Expand / Collapse