SSIS Package level OnError sends two emails

2019-05-06 23:57发布

问题:

I have a package that sends out two emails whenever a control flow element fails. For example, if the ExecuteSQL Task fails, the Package level OnError event handler fires two emails.

Is this a known issue? How do I get around this? I can do this through database driven scripts, but essentially, I would like to handle the situation on SSIS itself. Thanks for any help.

回答1:

Keep in mind that event handlers will raise events anytime the triggering action occurs. So, you're not guaranteed to only get one event using an event handler (with a few exceptions of course).

If you want to guarantee only one email then I would recommend not sending email via the OnError event and instead linking a 'Send Email Task' that is part of the control flow and connected to the ExecuteSQL task with a 'Failure Constraint'.

Or, you could also set a user variable equal to true in the OnError event and then send the email based on that with a 'On Completion' constraint mixed with an expression that checks the value of the Error user variable. That way, it doesn't matter how many times the OnError event raises as the task will only run if it was raised at least once.