SSIS包级别OnError发送两封电子邮件 [英] SSIS Package level OnError sends two emails

查看:139
本文介绍了SSIS包级别OnError发送两封电子邮件的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个程序包,每当控制流元素发生故障时,它都会发出两封电子邮件.例如,如果ExecuteSQL任务失败,则程序包级别的OnError事件处理程序将触发两封电子邮件.

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.

这是一个已知问题吗?我该如何解决? 我可以通过数据库驱动的脚本来完成此操作,但从本质上讲,我想处理SSIS本身的情况.感谢您的帮助.

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.

推荐答案

请记住,事件处理程序将在触发操作发生时随时引发事件.因此,您不能保证只能使用事件处理程序来获得一个事件(当然有一些例外).

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).

如果您只想保证一封电子邮件,那么我建议您不要通过OnError事件发送电子邮件,而应该将发送电子邮件任务"链接到控制流中,并通过失败约束"将其链接到ExecuteSQL任务

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'.

或者,您也可以在OnError事件中将用户变量设置为true,然后根据该电子邮件发送带有完成时"约束条件的电子邮件,该约束条件与检查Error用户变量值的表达式混合在一起.这样,OnError事件引发多少次都没有关系,因为只有至少引发一次该任务才会运行.

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.

这篇关于SSIS包级别OnError发送两封电子邮件的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆