How to create an email that run in the background as long as there is a timeout > 2 between 2 dates.
2 days the difference between the 2 dates otherwise there is a time overrun as in the photo (opening date1, closing date2 : date2 -date1 > 2 => mail)
CodePudding user response:
You can follow below steps:
- Create a background SQLAgent job, which runs on regular schedule, say daily once or every 12 hours, based on the notification schedule.
- This SQLAgent job, polls the schedule table and sends email using
sp_send_dbmail
. Use DATEDIFF(day,GETDATE(),TravelDate) < 2 to find out the travels within 2 days. send email using sp_send_dbmail