Home > Articles > Data > SQL Server

  • Print
  • + Share This
Like this article? We recommend

Step Object

As mentioned before, Task objects do the work of the Package. But how do Task objects know when to run, and in what order? This is where Step objects come in. A Step object is used to control a Task object. There is a one-to-one correlation between steps and tasks. For each task you have, you will have a corresponding step. You can add constraints (which will be covered in the third article) to steps to have tasks run in a specific order, or under specific conditions (the completion or failure of other tasks). Steps are created off the Package object by first creating a variable to hold the step using the Step2 object, and then we add it to the package like this:

Set <StepObject> = <PackageObject>.Steps.New 

After we have this Step object, we give it a name and an optional description like other objects, but we also must tell it which task it is supposed to control. This is done with the .TaskName property. You can look at the example or see the DTS Help file to see some of the other properties that are available. Be careful when you give it the task name to use—a small typo and your whole package can fail (at least the step containing the typo). I like to set some constants for my task names for this reason, and to make things a little easier to code and debug. For example, I can create a variable, say strXFerData, set it to the value of "XFerDataTask", and pass this variable around so that I can use my intellisense to remember its name and not worry about typos.

  • + Share This
  • 🔖 Save To Your Account