Sending email alert when SQL Server restarts

  • 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.

  • 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.

  • 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.

  • Great!

    Thanks

  • 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

  • Stops or restarts?

  • 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

  • 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

  • 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

  • Thanks a lot , this link found very useful! It's working for me. Thanks once again.

    regards,

    Sachin

  • Thanks..it is working when I restart the service..

    but if My server only stopped then how should i configure get alerts

Viewing 11 posts - 1 through 10 (of 10 total)

You must be logged in to reply to this topic. Login to reply