如果在表'table1'中的列'Volume'为NULL时SQL作业发送电子邮件警报,如何在SQL Server中安排作业?
一旦你设置了一个工作的Database Mail Profile,你就可以创建一个预定的SQL Agent Job,它在合适的时间表上根据需要用你的特定参数执行sp_send_dbmail
。
例如:
declare @NullCheck nvarchar(100);
set @NullCheck = (select YourColumn from YouTable);
if @NullCheck is null
execute msdb.dbo.sp_send_dbmail @profile_name = 'YourDBMailProfileName'
,@recipients = '[email protected]'
,@subject = 'Column is NULL'
,@body = 'The Column is currently NULL'