我的结构如下:
我有一行日期时间类型,我希望每次接近日期时,在15天前向我发送警报,并通过电子邮件发送给我。
如何在Server中设计它?它必须与存储过程一起使用吗?触发器?
发布于 2017-08-08 16:54:48
下面是一个可以用于过程的快速shell,然后将其安排为每天运行的作业。您可以根据需要更改IF的逻辑。
create procedure myProc
as
if (select datediff(day,max(cho_fec_vencimiento_lic),getdate()) from SomeTable) = 15
begin
exec msdb.dbo.sp_send_dbmail
@profile_name = null,
@recipients = 'email@domain.org',
@body = 'This is your email alert',
@body_format = 'TEXT',
@subject = 'Alert'
end
gohttps://stackoverflow.com/questions/45573867
复制相似问题