Run a child package with its own configuration file from a parent SSIS package

  • I have child package I wish to call from a parent package. The child package runs off a configuration file. Assuming I have to put an execute package in to the parent package to call the child, how do I attach a particular configuration file to the child package? I need the child package to be runnable on its own too, hence the need for it to have its own configuration file.

  • I'm not sure I fully understand your question, but here's nonetheless a first attempt at answering it.

    You are right that you will need an execute package task to run the child package from its parent.

    In the child package, you should use package configurations. The important thing to know here is that package configurations can set a variable or property multiple times where the last setting wins. If a configuration fails (either because the variable or property it is trying to set does not exist or - in the case of a configuration of type "Parent Package Variable" - the parent package variable does not exist), this will give a warning but this will not hinder your package executing.

    If the configurations are the same for both packages, you could use the same configuration file (or same configuration filter in case your configurations are stored in a database) for the child and the parent package.

    If the configurations are different, you have several options:

    - use different configuration files (one for the parent and one for the child)

    - use the parent configuration file in both packages, but then overwrite some values with settings specific to the child package using a second configuration file that is specific to the child and that is read after the first one

    If the settings in the child package are different depending on whether it is executed on its own or called from the parent package, you would do as above, but add a final configuration where you overwrite some values using Parent Package Variables. If the child package is executed on its own, the parent variables are not defined and this step will have no effect (you will see a warning though).

    PS: You can turn these warnings off, but you are discouraged to do this in a production environment.

    Regards,

    Willem
    http://wschampheleer.wordpress.com[/url]

  • wschampheleer (2/22/2010)


    I'm not sure I fully understand your question, but here's nonetheless a first attempt at answering it.

    You are right that you will need an execute package task to run the child package from its parent.

    In the child package, you should use package configurations. The important thing to know here is that package configurations can set a variable or property multiple times where the last setting wins. If a configuration fails (either because the variable or property it is trying to set does not exist or - in the case of a configuration of type "Parent Package Variable" - the parent package variable does not exist), this will give a warning but this will not hinder your package executing.

    Ok, understood. However, if I'm setting up a child package to be run via an execute package task in the parent, I don't get the option to use a particular configuration file. If the parent package overrides the child package then that's fine, I'll just place the same variables in my parent package and place them in the parent's configuration file.

    If the configurations are the same for both packages, you could use the same configuration file (or same configuration filter in case your configurations are stored in a database) for the child and the parent package.

    If the configurations are different, you have several options:

    - use different configuration files (one for the parent and one for the child)

    - use the parent configuration file in both packages, but then overwrite some values with settings specific to the child package using a second configuration file that is specific to the child and that is read after the first one.

    Think I see what you mean here, however, as I can't see how you can apply a configuration file in an execute package task how do you apply the different configuration file to the child? Could it be that in the parent, when you set up package configuration files in the parent (SSIS > Package Configurations...) that you add them in there in order you want them to apply? e.g. if you had a configuration file for the child setting variable var1, and the parent package configuration file sets values for variables var1, var2, var3, then you place two configuration files in there, one for var1 in child and the second to be var1 to var3 in the parent. The var1 in the second configuration (parent) file overwriting the var1 in the first (child config) file?

    If the settings in the child package are different depending on whether it is executed on its own or called from the parent package, you would do as above, but add a final configuration where you overwrite some values using Parent Package Variables. If the child package is executed on its own, the parent variables are not defined and this step will have no effect (you will see a warning though).

    PS: You can turn these warnings off, but you are discouraged to do this in a production environment.

  • You can use package configurations in both the parent and the child package independently. The configurations for the child package should be defined in that package, not in the parent package or through the execute package task (which is indeed not possible).

    Regards,

    Willem
    http://wschampheleer.wordpress.com[/url]

  • wschampheleer (2/22/2010)


    You can use package configurations in both the parent and the child package independently. The configurations for the child package should be defined in that package, not in the parent package or through the execute package task (which is indeed not possible).

    Sorry, I wasn't being clear I think. My current scenario is this:

    I have a package which uses a particular configuration file. This has been running independently as two separate sql agent job for a number of months now. There are two separate jobs as one uses the original configuration file as set up in BIDS, and the other uses another file with different values.

    I now have another package (the parent) which, as part of its run, needs to run the above package (the child).

    I'm currently in development of the parent, but it's highly likely I will have other variables that I need to add to the parent package's configuration file.

    Are you saying that, if I wanted the child package to run with different values to those in the child's original package configuration file setup in BIDS, then I need to add the same variable names in to my parent package as in my child configuration file and these will filter down in to the child when it runs as part of the parent?

  • You can reuse the child's configuration file in the parent and then add extra configurations in the parent package (e.g. you can have more than 1 configuration file in a package; if a value or property is set more than once, the latest setting wins).

    The configurations will not filter down from parent to child. If you want this to happen, then you need to define configurations of the type "Parent Package Variable" in the child. The name of the variable does not have to be the same in both packages.

    Regards,

    Willem
    http://wschampheleer.wordpress.com[/url]

  • wschampheleer (2/22/2010)


    You can reuse the child's configuration file in the parent and then add extra configurations in the parent package (e.g. you can have more than 1 configuration file in a package; if a value or property is set more than once, the latest setting wins).

    The configurations will not filter down from parent to child. If you want this to happen, then you need to define configurations of the type "Parent Package Variable" in the child. The name of the variable does not have to be the same in both packages.

    Mmm. If I change the package configuration for the child to be parent package variable in BIDS, won't this then mean that I cannot run the child independently?

  • You need to be careful reusing configuration files, if the file refers to an object that does not exist in BOTH packages then it throws an error (or might be an error, can't remember), but it throws something so I didn't ever share. Any data that the child package needed was passed from Parent Package Variables.

    CEWII

  • Where do you set up the parent package variable in configuration files? In the child via BIDS or the parent?

  • In the child via BIDS.

    Regards,

    Willem
    http://wschampheleer.wordpress.com[/url]

  • Elliott W (2/22/2010)


    You need to be careful reusing configuration files, if the file refers to an object that does not exist in BOTH packages then it throws an error (or might be an error, can't remember), but it throws something so I didn't ever share. Any data that the child package needed was passed from Parent Package Variables.

    CEWII

    It only produces a warning - this will never make a package fail so it is essentially harmless.

    Regards,

    Willem
    http://wschampheleer.wordpress.com[/url]

  • So that would mean that the only way I could run the child package independently would be if I created another parent package that only calls the child package on its own i.e. no other tasks. Correct?

  • You do it in the Child Package, it is just like any other package configuration, the downside is you have to type in the variable name there isn't a drop down.

    I would make sure to only use variables that are defined at the package level (package scoped). You don't have to do anything special in the parent package.

    Is that clear?

    CEWII

  • Griffster (2/22/2010)


    So that would mean that the only way I could run the child package independently would be if I created another parent package that only calls the child package on its own i.e. no other tasks. Correct?

    Not at all, the child package has access to the parent packages variables, the child package is not limited by the parent. What I was refering to is if you use files that contain several configurations that if ALL of those configurations don't exist in both it will throw warnings. I get around this by only placing one config element or related elements that always go together in a single file. Then I only configure the package to use the files specific to that package.

    CEWII

  • Griffster (2/22/2010)


    So that would mean that the only way I could run the child package independently would be if I created another parent package that only calls the child package on its own i.e. no other tasks. Correct?

    My suggestion would be to create (or keep) your child package so that it runs independently (i.e. with its own configurations). If and only if any of these configurations need to be different when the package is called from a parent package, then you would apply parent package variables.

    Regards,

    Willem
    http://wschampheleer.wordpress.com[/url]

Viewing 15 posts - 1 through 15 (of 30 total)

You must be logged in to reply to this topic. Login to reply