Executing a package from within a package

  • Hello,

    I creating a package in 7.0 that needs to execute another package via an ActiveX script. Here is my code.

    Set oDTS = DTSGlobalVariables.parent

    Set oStep = oDTS.Steps.New

    '*** Load Package

    oDTS.LoadFromSQLServer sSQLServer, , , DTSSQLStgFlag_Default, , , , szPackageName

    '*** Set Exec on Main Thread

    For Each oStep In oDTS.Steps

    oStep.ExecuteInMainThread = False

    Next

    '*** Execute

    oDTS.Execute

    oDTS.UnInitialize

    My problem is that when I load the package, I receive an error stating "DTSStep_DTSActiveScriptTask_5 already exists in collection." Basically, a step in the package I'm loading is named the same as one in the controlling package. I'm not sure of the correct way to rename steps. I think just renaming the step in the controlling package would solve my problem. If not, then could someone tell me how to workaround it.

    Thanks,

    Jason

  • By using DTSGlobalVariables.parent you are creating a package object which is referencing the current package.

    You need to create a new package object to load your stored package into.

    eg:

    Set oPkg = CreateObject("DTS.Package")
    
    oDTS.LoadFromSQLServer sSQLServer, , , DTSSQLStgFlag_Default, , , , szPackageName

    Thanks

    Phill Carter

    --------------------
    Colt 45 - the original point and click interface

  • That worked great! Thanks.

    I've got another question now. I am unable to execute the package unless I specify a SQL login. Does this method require SQL Authentication? My NT account is SA on both servers. Also, what context does the child package execute under?

    Thanks,

  • The 'DTSSQLStgFlag_Default' constant specifies that SQL Security is used.

    For Winodws Authentication use the 'DTSSQLStgFlag_UseTrustedConnection' constant instead.

    Thanks

    Phill Carter

    --------------------
    Colt 45 - the original point and click interface

Viewing 4 posts - 1 through 3 (of 3 total)

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