ExecutePackageTask Object
The ExecutePackageTask object runs another Data Transformation Services (DTS) package. The package can be located in Microsoft® SQL Server™ 2000 Meta Data Services, in SQL Server, or in a file. The package can be specified by name or by package or version globally unique identifier (GUID).

DTS global variables can be passed to the target package. For each such global variable, a GlobalVariable object, which defines the name of the variable and value, is added to the GlobalVariables collection of the ExecutePackageTask object. These global variables are distinct from the members of the GlobalVariables collection of the Package2 object that contains the ExecutePackageTask object. Use the InputGlobalVariableNames property to specify members of the parent package GlobalVariables collection that are to be created or set in the child package.
Steps in child packages can join the transactions of parent packages, if Microsoft Distributed Transaction Coordinator (MS DTC) is running.
Collections
GlobalVariables Collection | Properties Collection |
Properties
Methods
Execute Method |
Remarks
The New method of the Tasks collection of the Package object returns a reference to a Task object. The CustomTask property of the Task object returns a reference to the appropriate custom task object.
Example
The following Microsoft Visual Basic® code uses the Execute Package Task object to run a package located in the file VarPubsFields.dts, which is encrypted and requires the password "user" to access.
Public Sub Main()
'Run package stored in file C:\DTS_UE\TestPkg\VarPubsFields.dts.
Dim oPackage As DTS.Package
Dim oStep As DTS.Step
Dim oTask As DTS.Task
Dim oCustTask As DTS.ExecutePackageTask
Set oPackage = New DTS.Package
'Create step and task, link step to task.
Set oStep = oPackage.Steps.New
oStep.Name = "ExecPkgStep"
Set oTask = oPackage.Tasks.New("DTSExecutePackageTask")
Set oCustTask = oTask.CustomTask
oCustTask.Name = "ExecPkgTask"
oStep.TaskName = oCustTask.Name
oPackage.Steps.Add oStep
Set oStep = Nothing
'Specify package to be run.
oCustTask.PackagePassword = "user"
oCustTask.FileName = "C:\DTS_UE\TestPkg\VarPubsFields.dts"
'Link task to package, run package.
oPackage.Tasks.Add oTask
Set oCustTask = Nothing
Set oTask = Nothing
oPackage.Execute
Set oPackage = Nothing
End Sub