Thursday, January 22, 2009

Error Handling

SSIS provides advanced features for Error Handling. We can define error handling events for entire package as well individual events to handle failure in any particular control.


1. To write event handler for a particulat container, select that container object and move to Error handlers tab at the top.
2. Click on the link at the centre stating " Click here to create an 'OnError' event handler for executable ..."
3. You can write your custom code here to handle the error.
4. On Error, the package variables "ErrorCode", "ErrorDescription" and "SourceName" are populated.
a] SourceName holds the name of the task that failed.
b] ErrorCode holds the errorcode of the error that occurred.
c] ErrorDescription holds the description of the Error that occurred.

You can store all messages in an object by appending all messages thrown and notifying user at the end with one single notification.

Dts.Variables["User::ErrorMessages"].Value = Dts.Variables["User::ErrorMessages"].Value + "\r\n" + Dts.Variables["System::ErrorDescription"].Value;




5. You can use these variables to notify the users of the error that occurred.

No comments:

Post a Comment