The Logic of IF...THEN

Need the simplicity of the IF...THEN statement in your SSIS packages? It can be done.

One of the questions I am regularly asked is how to build IF...THEN logic into an SSIS package. While there are no built-in tasks or transformations that provide you an IF...THEN style comparison, there are a couple ways to make this happen. If you need this logic in your Control Flow, you can use Precedence Constraints and if you need it in your data flow, you use Conditional Split.

For Control Flow, the easiest thing to do is make your logical comparison in a script or with an expression and then set a variable value to use as an answer flag. For example, say you want to check for the existence of a particular file on disk. You can do that via a script task and then set an SSIS variable to True or False to indicate whether there are files. Then you can just edit the Precedence Constraint following the script to use an expression that checks your variable value (see Fig. 1). You can build as many paths after the script as you need. This allows you to mimic not only IF...THEN logic but also CASE logic.

Precedence Constraint dialog
Figure 1. To mimic an IF...THEN in the SSIS package, edit the Precedence Constraint that follows the script. (Click image to view larger version.)

Inside a Data Flow, the easiest thing to do is to use the Conditional Split transformation. I won't go into a lot of detail, but this transformation allows you to evaluate the data in your package and split it up based on values. In other words, you are able to send data down multiple paths based on the values in the data. Alternatively, you could write a custom transformation script if you feel you need something more complex.

While there are no tasks or transformation explicitly called IF...THEN, you can functionally create the same logic using the tips in this post. I hope this makes your SSIS package development just a little easier.

About the Author

Eric Johnson, SQL Server MVP, is the owner of Consortio Services in Colorado Springs providing IT systems management and technology consulting. He is also the President of the Colorado Springs SQL Server User Group. He can be contacted at


  • SameSite Cookie Changes Rolled Back Until Summer

    The Chromium Project announced on Friday that it's delaying enforcement of SameSite cookie changes, and is temporarily rolling back those changes, because of the COVID-19 turmoil.

  • Basic Authentication Extended to 2H 2021 for Exchange Online Users

    Microsoft is now planning to disable Basic Authentication use with its Exchange Online service sometime in the "second half of 2021," according to a Friday announcement.

  • Microsoft Offers Endpoint Configuration Manager Advice for Keeping Remote Clients Patched

    Microsoft this week offered advice for organizations using Microsoft Endpoint Configuration Manager with remote Windows systems that need to get patched, and it also announced Update 2002.

  • Azure Edge Zones Hit Preview

    Azure Edge Zones, a new edge computing technology from Microsoft designed to enable new scenarios for developers and partners, emerged as a preview release this week.

comments powered by Disqus

Office 365 Watch

Sign up for our newsletter.

Terms and Privacy Policy consent

I agree to this site's Privacy Policy.