I’m re-writing our SQL 2014 SSIS packages in SQL 2016. The main purpose of the re-write is to add additional error handling and intelligence to the packages. I’m looking for a little “best practice” guidance.
First I’ll give a brief explanation of our packages. They are written to process files we receive on our FTP site. We have a main “wrapper” (parent) package that does things like: copies the package to a working directory, unzip the file if necessary and then copies it to an archive directory. When the file is ready for processing, the parent package calls a sub-package (child) that does the cleansing/importing of the file, then calls a stored proc to do the final handling of the data.
I want to record errors as they occur, at whatever point they occur at, and gracefully exit the package. This means I need to write a record to a table, handled with an Exec SQL Task that calls a sproc, and then delete the file from the working directory, then send an email to people based on where the package failed. I’m wondering if the parent package should have one OnError event at the main package level or if it should have a separate OnError event for each step. I will do the same thing no matter where the error occurs – call the sproc to insert a record into the table. If the error occurs in the child package I also need to call the same sproc to insert a record into the table, but I also need the error to bubble up to the parent package so I know an error occurred. If an error occurs in the parent or the child, as the very last step(s) I need to delete the file I was processing, then call another sproc that is going to determine where the error occurred and whom to email. I’m not sure of the best way to accomplish all of this so I’m looking for suggestions.
I was thinking of having one OnError event at the parent package, and one at the child package. I can handle all the errors that way just fine, but I can’t handle the final cleanup/email step. I also don't know how to get the child package to tell the main package that an error has occurred.
Any help is appreciated. Thanks in advance.
André