我从哪里开始了解 SQL Server 警报或通知?

发布于 2024-07-05 00:23:27 字数 331 浏览 7 评论 0原文

最近刚刚开始遇到 SQL Server 代理作业的问题,该作业包含用于提取生产数据并将其汇总到单独的报告数据库中的 SSIS 包。

认为是我尝试使用的某些警报/通知设置导致了该问题,因为该作业在过去两周内一直在无人值守的情况下运行完成。

那么...哪里是开始阅读 SQL 代理警报和通知的好地方?
我想启用某种警报/通知,以便我始终收到通知:

  1. 作业成功完成(作为检查以确保它始终执行),或者
  2. 作业遇到某种错误,这应包含足够的信息(例如错误号),以便我可以诊断错误的原因

一如既往,任何帮助将不胜感激!

Just recently started having issues with an SQL Server Agent Job that contains an SSIS package to extract production data and summarize it into a separate reporting database.

I think that some of the Alerts/Notifications settings I tried playing with caused the problem as the job had been running to completion unattended for the previous two weeks.

So... Where's a good place to start reading up on SQL Agent Alerts and Notifications?
I want to enable some sort of alert/notification so that I'm always informed:

  1. That the job completes successfully (as a check to ensure that it's always executed), or
  2. That the job ran into some sort of error, which should include enough info (such as error number) that I can diagnose the cause of the error

As always, any help will be greatly appreciated!

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(3

囍笑 2024-07-12 00:23:27

在作业的每个步骤中单击“高级”,然后从那里您可以登录到文件或表,这将包含所有错误代码以及作业失败的其他原因
您也应该能够从工作历史中看到这一点。
右键单击作业 --> 查看历史记录,单击 + 号展开,单击每个步骤,它将出现在下部面板中

要设置通知,您需要设置操作员并在作业中您从电子邮件下拉列表中选择的通知选项卡

In each step of the job click on advanced then from there you can log to a file or to a table, this will have all errorcodes and other things why the job failed
You should be able to see this also from the job history.
Right click on the job-->view history, click on the + sign to expand, the click on each step and it will be in the lower panel

To set up notifications you need to set up an operator and the in the job on the notification tab you pick it from the email dropdown

Spring初心 2024-07-12 00:23:27

您需要在作业属性的通知页面中标记“作业完成时”。

只需转到该下拉列表并将其切换为作业完成而不是失败(在屏幕截图上)。

Job_Properties_Notification

您还需要确保您的服务器已配置电子邮件。 我认为它位于 SQL Surface Area Configuration for Features 下。

You'll want to have "When the job completes" marked in your notifications page on the job's properties.

Just go to that dropdown and switch it to job completion instead of failure (which is on the screenshot).

Job_Properties_Notification

You'll also want to make sure that your server has e-mail configured. I think it's under SQL Surface Area Configuration for Features.

听,心雨的声音 2024-07-12 00:23:27

联机丛书可能是一个不错的起点(或者至少我喜欢它并且通常发现它很有用)。

SQLMenace 和 bofe 提出了一些很好的观点。 这是我的另外两分钱:

我建议 配置数据库邮件 而不是 SQL Mail(即 SMTP 与 MAPI,我认为无论如何它已被弃用)。 配置邮件配置文件后,您还必须配置 SQL 代理以使用该邮件配置文件(这只是代理属性的设置页面),否则您的 SSIS 作业通知实际上不会发送,即使您可以从 Management Studio 成功发送测试电子邮件。

我使用警报的频率不如工作通知,因此我能记得的关于警报的唯一棘手的事情是,如果您提出错误并且希望警报在发生错误时通过电子邮件发送给您,则必须确保引发的错误将写入日志。 我认为这可以归结为“RAISERROR ...WITH LOG”; 以下是语法详细信息的 BOL 链接

Books Online is probably a good place to start (or at least I like it and generally find it useful).

SQLMenace and bofe made some good points. Here's my additional two cents:

I'd recommend configuring Database Mail rather than SQL Mail (i.e. SMTP vs. MAPI, which I think is deprecated anyway). Once you get the mail profile configured, you'll have to also configure the SQL agent to use that mail profile (which is just a page of settings for the agent properties), or else your SSIS job notifications won't actually get sent, even though you can successfully send a test email from Management Studio.

I don't use alerts as often as job notifications, so the only tricky thing I can recall about them is that if you're raising an error and you want the alert to email you when that happens, you have to make sure that the raised error gets written to the log. I think that just boils down to "RAISERROR ... WITH LOG"; here's the BOL link for the syntax details.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文