简体   繁体   English

SQL Server:更改自动生成的作业通知电子邮件

[英]SQL Server : change automatically generated Job Notification Email

Is it possible to change the automatically generated job notification email? 是否可以更改自动生成的工作通知电子邮件? In my case it generates a mail like this (translated by me): 就我而言,它会生成这样的邮件(由我翻译):

Subject: 学科:

SQLServer-Jobsystem: 'JobName' at \\ServerName\DatabaseName finished.

Body: 身体:

JobExecution:   'JobName' executed at '12.12.2014' 14:48:04.
Duration:   0 Hours, 0 Minutes, 1 Seconds
STATUS:     Successfully Finished
Messages:   The Job was successful. The Job has been executed by Schedule (Su 7:00) Last Executed Step 1 (JobName).

I want to define the subject and body by my self, but I cant find any stored procedures for this. 我想自己定义主题和正文,但是找不到任何存储过程。

I know of no way to modify the built in emails SQL Agent sends. 我知道没有办法修改SQL Agent发送的内置电子邮件。 The template is hard coded, as far as I'm aware. 据我所知,模板是硬编码的。

You could use customized notifications . 您可以使用自定义的通知 Basically, add a step after the last step in SQL Agent, then use that step to send the success email. 基本上,在SQL Agent的最后一步之后添加一个步骤,然后使用该步骤发送成功电子邮件。 Since it's the last step and every previous step said "Success: Go to next" and "Failure: Quit reporting failure", the only way the last step is running is if everything was a success. 因为这是最后一步,并且每个上一步都说“成功:转到下一步”和“失败:退出报告失败”,所以最后一步运行的唯一方法是一切都成功。 Now your new step can itself send the email for success. 现在,您的新步骤本身就可以发送成功电子邮件。

You could, theoretically, do the same for failure notices, but the logic gets a bit hairy then since the're not very good branching logic support in SQL Agent. 从理论上讲,您可以为失败通知做同样的事情,但是由于SQL Agent中对分支逻辑的支持不是很好,因此逻辑变得有些冗长。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM