SSIS - how to set ServerName and DatabaseName at run time inside FOREACH LOOP?

I am new to SSIS world, so my question is very basic.

Setup:

In a company I work for we have 12 SQL servers each running between 1 and 3 databases with anywhere between 10 to 20 tables. I need to query some of these tables and merge results to the destination database.

The list of all these tables is stored in the separate table <SOURCES> of the following format [ServerName,DatabaseName,TableName]. Tables of my interest have identical structure (same columns) accross servers and databases.

Question:

How can I loop over servers and databases specified in <SOURCES> to run otherwise identical query against these tables

I can easily retrieve [ServerName,DatabaseName,TableName] from <SOURCES> as string variables using FOREACH loop. The problem is now - how do I use string variables to set up Server, Database and Table name at run-time

Thank you

 

 

 

 

 

 



Answer this question

SSIS - how to set ServerName and DatabaseName at run time inside FOREACH LOOP?

  • zhonglixunni

    I've got a sample chapter in PDF format posted here that walks through a tutorial on how to do just that. It's about mid-way through the chapter. Hope it helps:

    http://www.whiteknighttechnology.com/cs/blogs/brian_knight/archive/2005/12/30/58.aspx

    -- Brian



  • Philip Lee

    From the For Each Loop pass the server and database values into variables. You can then use the variables in expressions on the connection. Select the connection, and in the properties window click Expressions, expend and add a new expression onto the properties you require, or just the connection string property itself. The expression can reference the variables.

  • SSIS - how to set ServerName and DatabaseName at run time inside FOREACH LOOP?