sqlserver 自定义发送邮件内容
declare @msg nvarchar(500), @sub nvarchar(100)
select @msg = case when msg = 'success' then '任务执行成功!' else msg end
, @sub = case when msg = 'success' then 'bipt-娇兰-etl-success' else 'bipt-娇兰-etl-fail' end
from GuerLain_CP.dbo.ETL_log
where id = (select max(id) from GuerLain_CP.dbo.ETL_Log where tb='cp_dataclean')
exec msdb.dbo.sp_send_dbmail
@profile_name = 'test', --配置名称
@recipients = 'bipm@test.cn', --收件人
@body_format = 'HTML', --内容格式
@subject = @sub, --主题
@body = @msg --正文
浙公网安备 33010602011771号