SSIS 中调用子包

从一个SSIS包调用另一个包,从表面上看挺简单.只需使用 ExecutePackage 任务,并指定一个SQLServer或文件系统中的一个包.如下

 

很简单,对吧.但是如果你需要父包传递信息到子包呢? 这可以通过在父包使用包变量,并且配置子包配置来完成.我们来看这个例子,我已经建好了两个包一个parent

,一个child. 在父包我添加了叫MessageToChild的变量

Then I added the execute package task we looked at earlier to call the child package. Within the child package, I added a variable called Message as shown below.

下一步就是得到父包变量的值,并传递到子包.这需要包配置帮助.在子包中我添加了Parent Package variable包配置,在其中使用了MessageToChild变量计算子包消息变量.

Okay, the next step is to get the Parent variable value into my child variable; this is where package configurations come into play. In the child package, I added a Parent Package Variable package configuration which uses the MessageoChild variable to populate the child’s Message variable.

当父包调用子包时,传递了变量值到子包. 通过添加以下脚本简单测试一下.

MsgBox(Dts.Variables.Item("Message").Value.ToString, MsgBoxStyle.OkOnly, "Message From Parent")

这个脚本弹出以下对话框.

你想传递的所有值必须存储在父包的包变量中,子包可以使用这些值设置自己的属性,你可以设置文件路径,表达式值,连接串,变量值等. 当然也可以用别的方式建立包间的对话机制,比如父包写表或文件,子包从表或文件中得到值.但是使用 ExecutePackage 任务是一个快速且高效的方式.

转载于:https://www.cnblogs.com/heitou/archive/2012/05/28/SSIS_%e5%8c%85_%e5%ad%90%e5%8c%85.html

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值