简体   繁体   中英

SSIS package - loop through different connections for Execute SQL task

I am creating an MSSQL2008 SSIS package to generate and email reports from database tables. It works perfectly on a single database. The client is running 3 different databases used by 3 different divisions. The database structure is exactly the same. All three databases are located on the same server, same security / credentials are used.

I created a "For Each Loop Container" in my SSIS package that loops through the list of 3 items and populates it into a variable. How do I now take that and pass it to the "Execute SQL Task" to run three times (once for each database)?

Thank you for your time!

It was a lot easier than I expected.

I went to Properties of the "Execute SQL Task" and under "Expressions" for "Connection" I specified @varDBName, which was the variable I populated in the outer "for each" loop. I also needed to set "DelayValidation" property to "True" so it's only evaluated during run-time. I hope this helps somebody else.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM