• Hi

    You won't be able to use the Bulk Insert Task because that only applies to files and not database connections. So if you want to use the Execute SQL task, you can do the following (this may not be the ideal way of doing it, but it works):

    SUMMARY:

    Read in the list of tables to variables -> Use a ForEach Loop container to read through each of these and amend an Execute SQL task on each loop -> Make the Execute SQL task do a simple TSQL insert.

    DETAILS:

    1. Set up a Linked Server (Server Objects > Linked Servers) to the source DB (if you can't use one of SQL Server's built-in providers then you can set up an ODBC connection and then connect to that).

    2. In SSIS create a variable of type Object

    3. Create a task that reads in the list of tables you need and maps to the variable. For example, you could have a database table that contains two columns such as SourceTable and DestinationTable. In that case use an Execute SQL task to do a simple select on that table, but make sure you then map that Result Set to the object variable.

    4. Create variables to hold each value. So in the example above, create one variable to hold the SourceTable name and one to hold the destination one.

    4. Create a ForEach Loop container. Edit the container and on the Collection section ensure the Enumerator is set to ForEach ADO Enumerator and you select the Object variable in the section below. Then go to the Variable Mappings and map each output from your select statement earlier to your variables. So for example, if your select statement in step 3 outputs 2 columns, then in the mappings section under variables select your SourceTable variable and under Index enter 0, and similarly select you DestinationTable variable and Index 1. So now your variables will contain the table names you need on each loop.

    5. Place an Execute SQL task inside the container. Edit the task and on the Expressions section, add an Expression for SqlStatementSource. Then give it a value of something like:

    "INSERT INTO " + @[User::DestinationTable] + " SELECT * FROM OPENQUERY(XXXXXXX, 'SELECT * FROM " + @[User::SourceTable] + "')"

    Here the XXXXX will be the name of the Linked Server you set up at the start. Of course, you can test the statement first in a normal SQL Query window to make sure it works first:

    INSERT INTO AAAAAAA

    SELECT * FROM OPENQUERY(XXXXXX, 'SELECT * FROM BBBBBB')

    where AAAAA is your destination table and BBBBB is your source table.

    One final note - if you can read directly from the source DB from SQL Server (e.g. if it is just another SQL Server DB), then you don't need to do step 1, and in the final step your SQL query will be even simpler, i.e. of the form:

    INSERT INTO AAAAA

    SELECT * FROM BBBBBB

    Hope that helps. Give me a shout if you still get stuck