INF: How To Find a Specific Task/Step Inside a DTS Package (235893)



The information in this article applies to:

  • Microsoft SQL Server 7.0

This article was previously published under Q235893

SUMMARY

From within a Data Transformation Package (DTS) you may need to get access to another Task/Step within the package itself. The "More Information" section has some sample code that you can place within your package that returns the preferred Task/Step.

MORE INFORMATION

Due to some design constraints within DTS, you must place these functions within the same Active Script Task that is trying to acquire a specific Task/Step. You cannot place this code into an Active Script Task within a package and treat it as a generic support routine. Each Active Script Task that you want to call in the functions must contain the following code:
Function FindTaskByName (strTaskName, oTask)
    Dim oPackage          ' the Package Object
    Dim nCount            ' simple counting variable
    Dim ReturnCode        ' function return code

    ReturnCode = False

    Set oPackage = DTSGlobalVariables.Parent

    For nCount = 1 To oPackage.Tasks.Count Step 1
        If oPackage.Tasks(nCount).Description = strTaskName Then
            Set oTask = oPackage.Tasks(nCount)
            ReturnCode = True
            Exit For
        End if
    Next
    FindTaskByName = ReturnCode
End Function

Function FindStepByName (strStepName, oStep)
    Dim oPackage 
    Dim nCount
    Dim ReturnCode

    ReturnCode = False

    Set oPackage = DTSGlobalVariables.Parent

    For nCount = 1 To oPackage.Steps.Count Step 1
        If oPackage.Steps(nCount).Description = strStepName Then
            Set oStep = oPackage.Steps(nCount)
            ReturnCode = True
            Exit For
	End If
    Next
    FindStepByName = ReturnCode
End Function
				

Modification Type:MajorLast Reviewed:3/25/2000
Keywords:kbCodeSnippet kbinfo KB235893