本文介绍了如何根据配置值有选择地执行子包?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个执行多个子包的 SSIS 包

I have an SSIS package that executes multiple child packages

pkg1
 |
 |
 |
pkg2
 |
 |
 |
pkg3

我想执行可配置的子包,以便我可以根据配置值更改要执行的子包.

I would like to execution of the child packages configurable so that I can change which child packages to execute based on the configuration values.

SSIS 中的哪个选项允许我启用/禁用父包中的子包执行?

Which option in SSIS would allow me to enable/disable the child package executions within the parent package?

推荐答案

您可以将执行包任务放在 Foreach 循环容器中并控制要通过表运行的包.正如你计划连续运行包,这种模式很适合你.

You can put a Execute package task inside a Foreach loop containerand control the packages to be run through a table. As you are planning to run the packages serially, this pattern will work well for you.

一些细节:

  1. 创建一个新表

  1. Create a new table

创建表 [dbo].[ActivePackages]([ID] [int] IDENTITY(1,1) 非空,[PackageName] varchar NOT NULL,[活动] [位] 非空) 在 [主要]

CREATE TABLE [dbo].[ActivePackages]( [ID] [int] IDENTITY(1,1) NOT NULL, [PackageName] varchar NOT NULL, [Active] [bit] NOT NULL) ON [PRIMARY]

插入两行

ID PackageName Active

ID PackageName Active

1 c_mp_Child1.dtsx 0

1 c_mp_Child1.dtsx 0

2 c_mp_Child2.dtsx 1

2 c_mp_Child2.dtsx 1

创建一个父包 (p_MainPackage.dtsx) 和两个子包 (c_mp_Child1.dtsx 和 c_mp_Child2.dtsx)

Create a parent (p_MainPackage.dtsx) and two child packages (c_mp_Child1.dtsx and c_mp_Child2.dtsx)

p_MainPackage.dtsx 的描述变量

Description of p_MainPackage.dtsxVariables

sActivePackageFullPath(字符串)

sActivePackageFullPath (String)

表达式:@[User::sSolutionFolder] + "\" + @[User::sActivePackage]

Expression: @[User::sSolutionFolder] + "\" + @[User::sActivePackage]

评估为表达式:真

sSolutionFolder 字符串

sSolutionFolder String

oActivePackages 对象 System.Object

oActivePackages Object System.Object

sActivePackage 字符串

sActivePackage String

执行 SQL 任务 -- 获取活动项目列表并存储在 oActivePackages 中

Execute SQL Task -- Get list of active projects and store in oActivePackages

Foreach 循环容器

Foreach Loop Container

枚举器:Foreacj ADO 枚举器ADO 对象源变量:User::oActiveProject变量映射

Enumerator: Foreacj ADO Enumerator ADO object source variables: User::oActiveProject Variable mapping

: User::sActivePackageFullPath6a.内部:执行包任务子包的连接字符串:@[User::sActivePackageFullPath]

: User::sActivePackageFullPath6a. Inside: Execute Package Task Connection String for the Child package: @[User::sActivePackageFullPath]

这篇关于如何根据配置值有选择地执行子包?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

10-17 00:16