Click here to monitor SSC
SQLServerCentral is supported by Red Gate Software Ltd.
 
Log in  ::  Register  ::  Not logged in
 
 
 
        
Home       Members    Calendar    Who's On


Add to briefcase 12»»

Sending email alert when SQL Server restarts Expand / Collapse
Author
Message
Posted Monday, November 24, 2008 11:46 PM
Grasshopper

GrasshopperGrasshopperGrasshopperGrasshopperGrasshopperGrasshopperGrasshopperGrasshopper

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.
Post #608101
Posted Tuesday, November 25, 2008 10:30 AM
SSC Veteran

SSC VeteranSSC VeteranSSC VeteranSSC VeteranSSC VeteranSSC VeteranSSC VeteranSSC Veteran

Group: General Forum Members
Last Login: Wednesday, September 17, 2014 7:27 AM
Points: 239, Visits: 504
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.
Post #608541
Posted Tuesday, November 25, 2008 9:52 PM
Grasshopper

GrasshopperGrasshopperGrasshopperGrasshopperGrasshopperGrasshopperGrasshopperGrasshopper

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.
Post #608837
Posted Wednesday, November 26, 2008 8:08 AM
SSC Veteran

SSC VeteranSSC VeteranSSC VeteranSSC VeteranSSC VeteranSSC VeteranSSC VeteranSSC Veteran

Group: General Forum Members
Last Login: Wednesday, September 17, 2014 7:27 AM
Points: 239, Visits: 504
Great!

Thanks
Post #609122
Posted Wednesday, January 21, 2009 2:42 PM
Forum Newbie

Forum NewbieForum NewbieForum NewbieForum NewbieForum NewbieForum NewbieForum NewbieForum 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
Post #641177
Posted Thursday, January 22, 2009 8:06 AM
SSC Veteran

SSC VeteranSSC VeteranSSC VeteranSSC VeteranSSC VeteranSSC VeteranSSC VeteranSSC Veteran

Group: General Forum Members
Last Login: Wednesday, September 17, 2014 7:27 AM
Points: 239, Visits: 504
Stops or restarts?
Post #641744
Posted Monday, December 6, 2010 10:24 PM
Forum Newbie

Forum NewbieForum NewbieForum NewbieForum NewbieForum NewbieForum NewbieForum NewbieForum 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
Post #1031021
Posted Sunday, July 15, 2012 11:50 PM
Forum Newbie

Forum NewbieForum NewbieForum NewbieForum NewbieForum NewbieForum NewbieForum NewbieForum Newbie

Group: General Forum Members
Last Login: Thursday, December 19, 2013 10:05 PM
Points: 3, Visits: 91
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
Post #1329941
Posted Tuesday, July 17, 2012 9:55 PM


Old Hand

Old HandOld HandOld HandOld HandOld HandOld HandOld HandOld Hand

Group: General Forum Members
Last Login: Friday, March 21, 2014 9:46 AM
Points: 387, Visits: 1,078
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
Post #1331190
Posted Wednesday, July 18, 2012 5:02 AM
Forum Newbie

Forum NewbieForum NewbieForum NewbieForum NewbieForum NewbieForum NewbieForum NewbieForum Newbie

Group: General Forum Members
Last Login: Thursday, December 19, 2013 10:05 PM
Points: 3, Visits: 91
Thanks a lot , this link found very useful! It's working for me. Thanks once again.

regards,
Sachin
Post #1331358
« Prev Topic | Next Topic »

Add to briefcase 12»»

Permissions Expand / Collapse