Friday, February 10, 2012

Changing variable scope in package templates?

Is there any way to change variable scope while using package templates?

I have created a package template that has several variables, a "typical" control flow and data flow. My goal was to try and use this as a starting point to create other packages within the same project and edit as required in the new package. I couldn't find any way (yet) to change scope of variables...these still show as belonging to the scope of package used to create the template.

Appreciate any help...thanks.

You can't change the scope of variables unfortunately.

Just drop it and recreate it instead.

-Jamie

|||

After some experimentation I was able to achieve this by directly editing the package file (.dtsx) and associated configuration (.dtsConfig) file. It is great that these are XML files. The basic steps follow:

Copy "template" .dtsx and .dtsConfig files and rename as desired.

In new files replace all "template" package name with new package name.

Open new package in SSIS - the variables are now in the new package scope.

Make sure you generate a new GUID for the new package within SSIS.

|||

I had created several variables in the wrong scope ..data flow scope that I needed to reference in the control flow.

Change variable scope -

1. created a dummy variable that I could Ctrl F easily in the control flow

2. under view -> Code

3. within the XML, Ctrl F the variable that was in the wrong scope and cut (ctrl X) the XML out of the dataflow scope.

4. paste the xml into the package scope directly underneath my dummy variable.

5. save XML (I saved as a different name to prevent corruption).

No comments:

Post a Comment