Solved

User SQL database mail to send warning

Posted on 2010-09-03
9
434 Views
Last Modified: 2012-05-10
Occassionally we have a service on a SQL stop; I have database mail working, at least I can send a test message to myself. Is there some way to use it to send an email when a server does not start after reboot or stops during the day?
0
Comment
Question by:LarryDAH
  • 3
  • 3
  • 2
  • +1
9 Comments
 
LVL 8

Expert Comment

by:dba2dba
ID: 33599087
Run this as a DOS Script. Schedule this as reuired or add as a startup script if needed.

------------------------------------------------------
@ECHO OFF
IF EXIST (SC query IISAdmin | FIND "STATE" | FIND "RUNNING")
sqlcmd
'
EXEC msdb.dbo.sp_send_dbmail ................

'
----------------------------------------------------------
Replace IISAdmin with the service name of interest. (Please note the actual service name in the properties and not go by name of service in services console)

Write appropriate dbmail command to send a message to you.

Thanks,
0
 

Author Comment

by:LarryDAH
ID: 33599652
The server I am interested in for th SQL server, so I changed IISAdmin to MSSQLServer. Using info at http://blog.sqlauthority.com/2008/08/23/sql-server-2008-configure-database-mail-send-email-from-sql-database/ I created a SQL query that sends and email to me when executed, but how would I tie it all together. If the SQL service stops under Recovery you can restart the service, restart the server, etc or execute a program. How would I get it to run my dbmail query?
0
 
LVL 7

Expert Comment

by:lundnak
ID: 33614350
Look at this link.  It describes out to execute a procedure on SQL Server startup.

http://msdn.microsoft.com/en-us/library/ms181720.aspx
0
 
LVL 75

Expert Comment

by:Anthony Perkins
ID: 33614610
>>How would I get it to run my dbmail query?<<
If there is no SQL Service then you cannot using database mail.
0
Highfive + Dolby Voice = No More Audio Complaints!

Poor audio quality is one of the top reasons people don’t use video conferencing. Get the crispest, clearest audio powered by Dolby Voice in every meeting. Highfive and Dolby Voice deliver the best video conferencing and audio experience for every meeting and every room.

 
LVL 8

Expert Comment

by:dba2dba
ID: 33617210
In this case, you can use some windows mailers.... BMAIL is one of them.

http://www.beyondlogic.org/solutions/cmdlinemail/cmdlinemail.htm

Thanks,

0
 
LVL 75

Expert Comment

by:Anthony Perkins
ID: 33618124
The part you are overlooking is in bold:
"How would I get it to run my dbmail query?"
No application or utility can be used to retrieve a query if there is no SQL Server service. Period.
0
 

Author Comment

by:LarryDAH
ID: 33618382
That makes sense, if the SQL service is stopped it will not send a query off to tell us that. WHat about using an Event ID trigger. How can I figure out what event id a stopped SQL service would be?
0
 
LVL 75

Expert Comment

by:Anthony Perkins
ID: 33622575
I am afraid I have no idea.
0
 

Accepted Solution

by:
LarryDAH earned 0 total points
ID: 33728252
I found a network monitor software package at activexperts.com that can do what I need, plus monitor a lot more than that.
0

Featured Post

Complete Microsoft Windows PC® & Mac Backup

Backup and recovery solutions to protect all your PCs & Mac– on-premises or in remote locations. Acronis backs up entire PC or Mac with patented reliable disk imaging technology and you will be able to restore workstations to a new, dissimilar hardware in minutes.

Join & Write a Comment

Suggested Solutions

Everyone has problem when going to load data into Data warehouse (EDW). They all need to confirm that data quality is good but they don't no how to proceed. Microsoft has provided new task within SSIS 2008 called "Data Profiler Task". It solve th…
Load balancing is the method of dividing the total amount of work performed by one computer between two or more computers. Its aim is to get more work done in the same amount of time, ensuring that all the users get served faster.
Using examples as well as descriptions, and references to Books Online, show the documentation available for date manipulation functions and by using a select few of these functions, show how date based data can be manipulated with these functions.
Viewers will learn how the fundamental information of how to create a table.

744 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

10 Experts available now in Live!

Get 1:1 Help Now