Académique Documents
Professionnel Documents
Culture Documents
Case
An often seen solution is a master package calling a couple of child packages with the Execute
Package Task. This works fine for a couple of packages, but is a little boring for a whole bunch of
packages. Is there an easier more clear way to maintain a master package?
Solution
A simple solution is to use a Foreach Loop Container with an Execute Package Task in it that loops
through a folder with packages. It works both for file-based and server-based packages.
A) File based
1) Variable
Add a string variable to the package and name it PackagePath. This will contain the filepath of the
package.
2) Foreach Loop
Add a foreach loop to your master package. Edit it to give it a suitable name and to select the File
Enumerator. If you need a certain order then you could install the Sorted File Enumerator.
File Enumerator
4) Variable Mappings
Go to the variable mappings pane and select the variable from step 1. This will fill the variable with the
path of the current package.
6) Expression
Go to the properties of your newly created File Connection Manager and add an expression on the
ConnectionString property that overrules its value with the variable PackagePath from step 1.
7) The result
A clear package with only one Execute Package Task and one Connection Manager.
Case
An often seen solution is a master package calling a couple of child packages with the Execute
Package Task. This works fine for a couple of packages, but is a little boring for a whole bunch of
packages. Is there an easier more clear way to maintain a master package?
Solution
A simple solution is to use a Foreach Loop Container with an Execute Package Task in it that loops
through a folder with packages. It works both for file-based and server-based packages.
1) Variables
Add a string variable to the package and name it PackagePath. This will contain the filepath of the
package. Also create an object variable named Packages. This will contain a list of packages from the
MSDB.
1
2
3
4
5
6
7
8
Result Set
5) Foreach Loop
Add a Foreach Loop Container to the control flow and give it a suitable name. Then connect the
Execute SQL Task to the Foreach Loop.
7) Variable Mapping
Go to the Variable Mapping pane and select the PackagePath variable for index 0.
Variable Mappings
9) Expression
Go to the properties of your newly created Execute Package Task and add an expression on
the PackageName property that overrules its value with the variable PackagePath from step 1.
Case
An often seen solution is a master package calling a couple of child packages with the Execute
Package Task. This works fine for a couple of packages, , but is a little boring for a whole bunch of
packages. Is there an easier more clear way to maintain a master package?
Solution
A simple solution is to use a Foreach Loop Container with an Execute Package Task in it that loops
through a folder with packages. It works both for file-based and server-based packages.
But there are a couple of drawbacks:
Drawback 1: The child packages are not executed simultaneously, but one after another. Will handle
this problem in a future post.
Drawback 2: The options to determine the order of execution are limited. You can only order by
name. So if a certain order is required then you need to add some prefix to the packagename to
determine the order.
I have prepared three solutions:
A) File based: SSIS 2005, 2008 or 2012 if you use package deployment.
B) SQL Server based: SSIS 2005, 2008 or 2012 if you use package deployment.
C) Project Referenced: SSIS 2012 if you use project deployment. This solution is nearly equal to
solution B.
C) Project Referenced
For this solution, you need to create a query on the SSISDB database to get the list of packages from
Integration Service. For this query we need the tables internal.packages and internal.projects.
1) Variables
Add a string variable to the package and name it PackagePath. This will contain the filepath of the
package. Also create an object variable named Packages. This will contain a list of packages from the
SSISDB.
1
2
3
4
5
6
7
8
AND
Packages.name like 'STG%'
ORDER BY Packages.name
Result Set
5) Foreach Loop
Add a Foreach Loop Container to the control flow and give it a suitable name. Then connect the
Execute SQL Task to the Foreach Loop.
7) Variable Mapping
Go to the Variable Mapping pane and select the PackagePath variable for index 0.
Variable Mappings
9) Expression
Go to the properties of your newly created Execute Package Task and add an expression on
the PackageName property that overrules its value with the variable PackagePath from step 1.