Software Development
Blogs and Discussion
developer.*
Books Articles Blogs Subscribe d.* Gear About Home

SSIS Design Technique: Using a Dummy Script Task to Enable Conditional Top-Level Tasks

Here's a SQL2K5 Integration Services control-of-flow design quandry I've encountered more than once: I have a task (any task, say for instance an FTP task) that I want to execute conditionally, but it does not have a direct parent task. For example, my hypothetical FTP task could be the first task inside of a sequence container, and as such has no direct parent. Since you can't have a precedence constraint (as far as I know) between a container and one of it's children, you're stuck without a place to put an expression to control whether your conditional task should execute.

One solution I tried using an Expression attached to the Disable property, but the problem I ran into there is that expressions are evaluated, as far as I can tell from the documentation, when the task is validated. The particular task I tried this on was inside of a Foreach container, and it appeared that the expression was being evaluated before my Foreach-related variable was being initialized. Maybe in a different circumstance the trick of attaching an expression to Disable would have worked...

So I came up with a little trick that has worked well: I added a Script task, did not add any code to it, and called it scrDummy. Basically, this sets up a situation where the Script task will always execute, always succeed, and do absolutely nothing. Then I made a precedence constraint from scrDummy to my conditional task, which in this case was an FTP task. Then I attached an expression to the precedence constraint, and everything worked great because not only do I have a home for my expression, the expression is evaluated at execution time and not validation time.

See also "Sequence Container as Indirection Mechanism to Enable Flow," which describes another SSIS design pattern I have used in conjunction with this pattern.

Comments welcome.

Dan

expression is evaluated at execution time not validation time

Thanks. I was going crazy with why my original expression on the task was "not working"

Comment viewing options

Select your preferred way to display the comments and click "Save settings" to activate your changes.

Recent comments

User login

About our advertising.

Atom Feed

developer.* Blogs also has an Atom feed, located at this url.

Click here for more information about Atom.

A Jolt Award Finalist
Software Creativity 2.0
Foreword by Tom DeMarco

Recent Posters

Based on most recent 60 days, sorted by # of posts and name.

Google
Web developer.*

Who's online

There are currently 0 users and 20 guests online.

Syndicate

Syndicate content
All views expressed by authors, bloggers, and commentors are their own and do not necessarily reflect the views of developer.* or its proprietors.
Click to read the Copyright Notice.

All content copyright ©2000-2005 by the individual specified authors (and where not specified, copyright by Read Media, LLC). Reprint or redistribute only with written permission from the author and/or developer.*.

www.developerdotstar.com