SQL Clone
SQLServerCentral is supported by Redgate
 
Log in  ::  Register  ::  Not logged in
 
 
 


SSIS - Run a query for multiple servers and stored resultset in local database/table?!


SSIS - Run a query for multiple servers and stored resultset in local database/table?!

Author
Message
WebTechie
WebTechie
SSCrazy
SSCrazy (2.4K reputation)SSCrazy (2.4K reputation)SSCrazy (2.4K reputation)SSCrazy (2.4K reputation)SSCrazy (2.4K reputation)SSCrazy (2.4K reputation)SSCrazy (2.4K reputation)SSCrazy (2.4K reputation)

Group: General Forum Members
Points: 2425 Visits: 1110
Well, I got that part to work.

I had to put quotes at the beginning and the end of the expression.

After that, it evaluated properly.

Now the last part:


1. Load the list of instances you want to iterate over into SSIS however you're doing that now.
2. Add a Foreach loop to your Control Flow and configure it to iterate over your list of instances however you're doing that now.
3. Setup an OLE DB Connection object and setup an Expression for the ConnectionString property to have it point to the current server in your Foreach loop.
4. Setup another OLE DB Connection object and have it point to the DB where your "master" table resides.
5. Add a Data Flow Task to your Control Flow.
6. In your Data Flow Task, use an OLE DB Source to get the data from each server
7. In your Data Flow Task, use an OLE DB Destination to load the data from the OLE DB Source into a table.



If I have an OLE DB source which is dynamically set #6 and a OLE db destination #7, how am I running a query?

For every server, I need to:

1) Run a query
2) Take the resultset of that query and place it into the OLE destination table.


Thanks guys for your help in this.

Tony
Welsh Corgi
Welsh Corgi
One Orange Chip
One Orange Chip (25K reputation)One Orange Chip (25K reputation)One Orange Chip (25K reputation)One Orange Chip (25K reputation)One Orange Chip (25K reputation)One Orange Chip (25K reputation)One Orange Chip (25K reputation)One Orange Chip (25K reputation)

Group: General Forum Members
Points: 25868 Visits: 4895
How about a SQL Task inside a Foreach Loop Container?

For better, quicker answers on T-SQL questions, click on the following...
http://www.sqlservercentral.com/articles/Best+Practices/61537/

For better answers on performance questions, click on the following...
http://www.sqlservercentral.com/articles/SQLServerCentral/66909/
Orlando Colamatteo
Orlando Colamatteo
SSC-Dedicated
SSC-Dedicated (37K reputation)SSC-Dedicated (37K reputation)SSC-Dedicated (37K reputation)SSC-Dedicated (37K reputation)SSC-Dedicated (37K reputation)SSC-Dedicated (37K reputation)SSC-Dedicated (37K reputation)SSC-Dedicated (37K reputation)

Group: General Forum Members
Points: 37964 Visits: 14411
WebTechie38 (7/21/2011)
Well, I got that part to work.

I had to put quotes at the beginning and the end of the expression.

After that, it evaluated properly.

Now the last part:


1. Load the list of instances you want to iterate over into SSIS however you're doing that now.
2. Add a Foreach loop to your Control Flow and configure it to iterate over your list of instances however you're doing that now.
3. Setup an OLE DB Connection object and setup an Expression for the ConnectionString property to have it point to the current server in your Foreach loop.
4. Setup another OLE DB Connection object and have it point to the DB where your "master" table resides.
5. Add a Data Flow Task to your Control Flow.
6. In your Data Flow Task, use an OLE DB Source to get the data from each server
7. In your Data Flow Task, use an OLE DB Destination to load the data from the OLE DB Source into a table.



If I have an OLE DB source which is dynamically set #6 and a OLE db destination #7, how am I running a query?

For every server, I need to:

1) Run a query
2) Take the resultset of that query and place it into the OLE destination table.


Thanks guys for your help in this.

Tony



The OLE DB Source will contain your query. In the source you can issue any valid SQL query including calling a stored proc.

__________________________________________________________________________________________________
There are no special teachers of virtue, because virtue is taught by the whole community. --Plato
Welsh Corgi
Welsh Corgi
One Orange Chip
One Orange Chip (25K reputation)One Orange Chip (25K reputation)One Orange Chip (25K reputation)One Orange Chip (25K reputation)One Orange Chip (25K reputation)One Orange Chip (25K reputation)One Orange Chip (25K reputation)One Orange Chip (25K reputation)

Group: General Forum Members
Points: 25868 Visits: 4895
Ah yes, create an OLE DB Source in the Connection Manager as well.

You will dynamically set the connection properties.

You may find this article useful.

http://www.simple-talk.com/sql/ssis/working-with-property-expressions-in-sql-server-integration-services/

For better, quicker answers on T-SQL questions, click on the following...
http://www.sqlservercentral.com/articles/Best+Practices/61537/

For better answers on performance questions, click on the following...
http://www.sqlservercentral.com/articles/SQLServerCentral/66909/
WebTechie
WebTechie
SSCrazy
SSCrazy (2.4K reputation)SSCrazy (2.4K reputation)SSCrazy (2.4K reputation)SSCrazy (2.4K reputation)SSCrazy (2.4K reputation)SSCrazy (2.4K reputation)SSCrazy (2.4K reputation)SSCrazy (2.4K reputation)

Group: General Forum Members
Points: 2425 Visits: 1110
Putting the query in the OLE DB source worked well.

That did it! Task complete.

I can now run this on all production servers and keep the results a monitoring database.

Thanks for all your help. I can now use this knowledge in quite a lot of upcoming projects.

Thanks again,

Tony
Welsh Corgi
Welsh Corgi
One Orange Chip
One Orange Chip (25K reputation)One Orange Chip (25K reputation)One Orange Chip (25K reputation)One Orange Chip (25K reputation)One Orange Chip (25K reputation)One Orange Chip (25K reputation)One Orange Chip (25K reputation)One Orange Chip (25K reputation)

Group: General Forum Members
Points: 25868 Visits: 4895
WebTechie38 (7/21/2011)
Putting the query in the OLE DB source worked well.

That did it! Task complete.

I can now run this on all production servers and keep the results a monitoring database.

Thanks for all your help. I can now use this knowledge in quite a lot of upcoming projects.

Thanks again,

Tony


I'm glad that the members on this forum were able to assist you.

Your are in the processing of developing an arsenal of SSIS Projects.

Check them into Source Control and save them on your own media.

Once you get in the grove you will be on a roll. Cool

For better, quicker answers on T-SQL questions, click on the following...
http://www.sqlservercentral.com/articles/Best+Practices/61537/

For better answers on performance questions, click on the following...
http://www.sqlservercentral.com/articles/SQLServerCentral/66909/
Go


Permissions

You can't post new topics.
You can't post topic replies.
You can't post new polls.
You can't post replies to polls.
You can't edit your own topics.
You can't delete your own topics.
You can't edit other topics.
You can't delete other topics.
You can't edit your own posts.
You can't edit other posts.
You can't delete your own posts.
You can't delete other posts.
You can't post events.
You can't edit your own events.
You can't edit other events.
You can't delete your own events.
You can't delete other events.
You can't send private messages.
You can't send emails.
You can read topics.
You can't vote in polls.
You can't upload attachments.
You can download attachments.
You can't post HTML code.
You can't edit HTML code.
You can't post IFCode.
You can't post JavaScript.
You can post emoticons.
You can't post or upload images.

Select a forum

































































































































































SQLServerCentral


Search