存储过程的 SQL 警报?
我有一个 SQL 2005 设置并且相当新:) 我已经解决这个问题几个小时了,我只需要一些帮助。
我已经能够成功地为标准“SQL 服务器性能事件”设置警报,这很有趣。所以我已经可以使用电子邮件提醒了。 但是,我需要警报来运行我创建的存储过程,并且根据其输出,它会通过电子邮件提醒我或不提醒我。
到目前为止,我一直在尝试使用 WMI 事件,但我不断收到错误“@wmi_query 无法在提供的 @wmi_namespace 中执行。验证查询中选择的事件类是否存在于命名空间中,并且查询已正确的语法”
查询肯定有效,所以我不知道..有没有不同的方法来做到这一点?
I have a SQL 2005 setup and am rather new :)
Been cracking at this for a few hours and I just need some help.
I have been able to setup alerts successfully for the standard "SQL server performance events", its fun. So I already have email alerts working.
However I need the alert thing to run a stored procedure I have created, and depending on its output it will alert me or not via email.
So far I have been trying to use the WMI events, but I keep getting an error "The @wmi_query could not be executed in the @wmi_namespace provided. Verify that an event class selected in the query exists in the namespace and that the query has the correct syntax"
the query definitely works so I have no idea.. is there a different way to do this?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
您可以使用 Management Studio 或 sp_add_alert 系统存储过程来添加警报并指定在触发时执行的作业。在 Management Studio 中,当您查看警报的属性时,它位于“响应”页面上。该作业可以由调用存储过程的一个步骤组成。在存储过程中,您可以使用
sp_send_dbmail
系统存储过程根据您定义的逻辑发送电子邮件。来自联机丛书:
You can use Management Studio or the
sp_add_alert
system stored procedure to add an alert and specify a job to execute on firing. In Management Studio, when you view the properties of the Alert, it is on the "Response" page. That job can consist of a single step calling your stored procedure. In your stored procedure, you can use thesp_send_dbmail
system stored procedure to send an email based on logic you define.From Books Online: