|
|
|
Grasshopper
      
Group: General Forum Members
Last Login: Wednesday, March 28, 2012 8:10 AM
Points: 12,
Visits: 84
|
|
Hi,
Is there a way to setup email notification to be sent whenever SQL server (or server agent) restarts? This is basically for monitoring server crashes/restarts.
Thanks in advance. Cheers! Vinay.
|
|
|
|
|
SSC Veteran
      
Group: General Forum Members
Last Login: Friday, May 03, 2013 10:08 AM
Points: 223,
Visits: 424
|
|
Assuming you know how to send emails from your server:
1. Create a stored procedure which sends an email alert when you execute it 2. Create a job, which executes this stored procedure, and when scheduling it, choose an option to start whenever Server Agent starts
So, whenever agent restarts, job will be run, sp will be executed, and alert email will be sent out.
And if whenever your SQL Server restarts, your agent also starts automatically, then you will always get an email whenever either SQL Server restarts or just agent restarts.
|
|
|
|
|
Grasshopper
      
Group: General Forum Members
Last Login: Wednesday, March 28, 2012 8:10 AM
Points: 12,
Visits: 84
|
|
This worked out perfectly. Thanks a lot :)
I figured out one more way to accomplish this. This is for notifying the SQL Server restart (not Agent) and can be implemented like this - 1. Set the “scan for startup procs” value to ‘true’ This can be done in the following way – a. Right click on the server instance in management studio’s object explorer. b. Go to Properties --> Advanced c. Change value of ‘Scan for Startup Procs’ to ‘True’ and click Ok.
2. Stop and restart SQL Server for the change to take effect.
3. Create a procedure in the master database which sends the required mail. (This procedure should be in the master database only). Let the procedure name be P
4. Set procedure P for autoexecution (to be run when the server’s startup) using the procedure sp_procoption.
This will bind procedure P to startup, and P will be executed every time the server starts up.
Cheers, Vinay.
|
|
|
|
|
SSC Veteran
      
Group: General Forum Members
Last Login: Friday, May 03, 2013 10:08 AM
Points: 223,
Visits: 424
|
|
|
|
|
|
Forum Newbie
      
Group: General Forum Members
Last Login: Tuesday, May 11, 2010 10:15 AM
Points: 1,
Visits: 21
|
|
I implemented the same with positive results .. Thanks a lot for the same .. I want to trigger email alert when SQL Server 2005 service stops. Can anybody help me with this ?
-- R
|
|
|
|
|
SSC Veteran
      
Group: General Forum Members
Last Login: Friday, May 03, 2013 10:08 AM
Points: 223,
Visits: 424
|
|
|
|
|
|
Forum Newbie
      
Group: General Forum Members
Last Login: Tuesday, May 28, 2013 6:05 AM
Points: 2,
Visits: 285
|
|
Hi,
I'm searching for past couple of days, can you kinldy share the script which sends a notification when ever sql server restarts.
Kindly help me...
Regards, Venkat
|
|
|
|
|
Forum Newbie
      
Group: General Forum Members
Last Login: Tuesday, May 07, 2013 11:58 PM
Points: 3,
Visits: 87
|
|
Hi,
We are also searching for the script, it will be helpful if anyone can share the scipt to receive the SQL server service restart notification!
Thanks, Sachin
|
|
|
|
|
Old Hand
      
Group: General Forum Members
Last Login: Yesterday @ 9:52 PM
Points: 329,
Visits: 533
|
|
This link can help you. http://www.mssqltips.com/sqlservertip/1663/auto-notification-for-failover-of-a-server-and-restart-of-sql-server-services/
For this, you need to enable database mail(sql server 2008/2005) or sqlmail (sql server 2000
|
|
|
|
|
Forum Newbie
      
Group: General Forum Members
Last Login: Tuesday, May 07, 2013 11:58 PM
Points: 3,
Visits: 87
|
|
Thanks a lot , this link found very useful! It's working for me. Thanks once again.
regards, Sachin
|
|
|
|