posted 1/25/2010 5:32:14 PM by MikeDavis
In some instances you will want to check to see if another package was successful or failed before running a second package. If you have it set up as a master package calling a child this is easy. What if the package is in a separate job, not associated with the first package at all? You could have the first package write the results to a database or file and then read that in with an execute SQL task in the second package. There is an easier way to accomplish this. Simply set up the first package to create a checkpoint file if it fails. Then have the second package check for the existence of this checkpoint file. You can even have the second package delete the checkpoint file if need be.
The first thing we will do is create two variables on the second package, one string variable with the checkpoint file path. The other is a boolen variable which will be set to true if the checkpoint file exist. We default the boolen variable to false.
Then we create a script tasks and have it check to see if the file exist. You will need to pass in the file name variable as a read only variable and the boolean variable as a read write variable. The VB code in the script task will be:
Dts.Variables("bolFileExist").Value = System.IO.File.Exists(Dts.Variables("strCheckFile").Value)
Then the precednece constraint coming out of the script task will need to be changed to include the expression @bolFileExist == True if you want to run the package when the file exist. Of course you can change the true to false if you need the opposite.
Here you can see the expression after the script task. Now the rest of the package will run based on the check point files existance. You can use this same technique to check for the existence of any files.
If you do not want the first package to use the checkpoint, you can use a file system task in the second package to delete the checkpoint file. Keep in mind if you do not delete the checkpoint file the first package will start from the failed point and not from the begining.
MikeDavis (Member since: 10/27/2009 8:52:44 AM) Mike Davis, MCTS, MCITP, Senior Business Intelligence Consultant at Pragmatic Works. He is an author on two Business Intelligence books. Mike is an experienced speaker and has presented at many events such as several SQL Server User Groups across the US, Code Camps, SQL Server Launches, and SQL Saturday events. Mike is an active member at his local user group (JSSUG) in Jacksonville, FL.
View MikeDavis 's profile
Leave a comment
It's fast, easy and free! Submit articles, get your own blog, ask questions & give answers in the forums, and become a better developer, faster.
enter your email address: