SSIS包—通过不同的连接循环执行SQL任务

时间:2022-11-25 05:38:13

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.

我正在创建一个MSSQL2008 SSIS包,以从数据库表生成和电子邮件报告。它在单个数据库上运行良好。客户端运行3个不同分区使用的3个不同的数据库。数据库结构完全相同。所有三个数据库都位于同一个服务器上,使用相同的安全性/凭据。

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)?

我在SSIS包中创建了一个“For Each Loop Container”,它循环遍历3个条目的列表,并将其填充到一个变量中。现在如何将其传递给“执行SQL任务”以运行三次(每个数据库一次)?

Thank you for your time!

感谢您的时间!

1 个解决方案

#1


5  

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.

我访问了“执行SQL任务”的属性,并在“连接”的“表达式”下指定了@varDBName,这是我在“for each”循环外部填充的变量。我还需要将“DelayValidation”属性设置为“True”,以便在运行时进行评估。我希望这能帮助别人。

#1


5  

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.

我访问了“执行SQL任务”的属性,并在“连接”的“表达式”下指定了@varDBName,这是我在“for each”循环外部填充的变量。我还需要将“DelayValidation”属性设置为“True”,以便在运行时进行评估。我希望这能帮助别人。