Chapter 48

Using Event Handlers

Although the main tasks of SSIS packages exist in either the Control Flow or the Data Flow, the Event Handlers tab, the subject of this lesson, is another tab that is very useful when you are creating a package. Event handlers enable you to call tasks when events like errors or warnings occur during the execution of a package, which can be helpful in logging errors or sending notifications. The Event Handlers tab is used to call a task when an event has occurred in the package. The tasks in the event handler run only if the proper event is called in the package. Therefore, it is possible to have tasks in the event handlers of a package that don’t run during the execution of the package because the proper event is not called.

Several events can occur in a package to cause an event to fire and call an event handler:

  • OnError
  • OnExecStatusChanged
  • OnInformation
  • OnPostExecute
  • OnPostValidate
  • OnPreExecute
  • OnPreValidate
  • OnProgress
  • OnQueryCancel
  • OnTaskFailed
  • OnVariableValueChanged
  • OnWarning

The most commonly used events are OnError, OnWarning, OnPreExecute, and OnPostExecute.

  • The OnError event fires when an error occurs during the execution of the selected executable.
  • The OnWarning event fires when a warning occurs during the execution of the selected executable.
  • The OnPreExecute event fires just before the selected executable starts executing.
  • The OnPostExecute event fires just after the selected executable finishes executing.

Creating Event Handlers ...

Get Knight's Microsoft SQL Server 2012 Integration Services 24-Hour Trainer now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.