SQL Server Restart Notification
If you ever wanted to be notified by email when your SQL Servers are restarted, here is a script which will do just that. It relies on using the "run on Agent Manager startup" option in SQL Jobs.
Download SQL Server Restart Notification (Size 2 KiB)
What it does:
This script sets up a scheduled job which will run when the Agent Manager is started. Should tempdb be recently created then this usually indicates that the SQL Server instance has been started. The script then issues an email with the date and time the server was started.
- SQL Server 2005 and above.
- You must already have Database Mail setup to support sp_send_dbmail.
- Run the script.
- Go to the newly created job called "SQL Server Restart Notification" under SQL Server Agent + Jobs.
- Edit the job and go to Step 1.
- Change the line @recipients = 'email@example.com' to be the email address you want to send the alerts to.
- Optional: You may also enable the Notifications section so that someone is alerted if this particular job fails for whatever reason.