Gen*_*нин 6 sql-server maintenance sql-server-2012
Windows Server 2008R2 上的 SQL Server 2012 R2
有什么方法可以将通知发送到不同的电子邮件:
你必须使用 tsql 来做到这一点。
在主要工作步骤之后的工作步骤中,再添加 2 个工作步骤:
第 2 步 - 成功电子邮件
EXEC msdb.dbo.sp_send_dbmail
@profile_name = 'YOUR MAIL PROFILE',
@recipients = 'COMPANYMAIL@COMPANY.COM',
@body = 'Copy and Purge BAKs success !!',
@subject = 'Copy and Purge BAKs success',
-- to send file attachments
@file_attachments = 'D:\logs\log.TXT',
-- Change below if you want to include query results from a table in the email.
-- Note that below is not in HTML
@query = 'select column1, column2 from table1';
Run Code Online (Sandbox Code Playgroud)
第 3 步 - 失败电子邮件
EXEC msdb.dbo.sp_send_dbmail
@profile_name = 'YOUR MAIL PROFILE',
@recipients = 'COMPANYMAIL@COMPANY.COM',
@body = 'Copy and Purge BAKs failed !!',
@subject = 'Copy and Purge BAKs failed',
-- to send file attachments
@file_attachments = 'D:\logs\log.TXT',
-- Change below if you want to include query results from a table in the email.
-- Note that below is not in HTML
@query = 'select column1, column2 from table1';
Run Code Online (Sandbox Code Playgroud)
然后使用 tsql sp_send_dbmail
注意:如果您希望发送 HTML 电子邮件,我有一个脚本可以帮助您。
归档时间: |
|
查看次数: |
4231 次 |
最近记录: |