August 15, 2006 at 11:53 am
Hello
I would like to know a script to check if the database is running or not and mail it to the dba mail box.
Thanks
August 15, 2006 at 12:30 pm
One way I have done this is to check the status of the server by issueing a command like:
xp_cmdshell 'sc \\yourservername query mssqlserver'
You could then input the results into a table and absed on the result issue a xp_sendmail command.
August 15, 2006 at 1:11 pm
Thanks for the command.
Can you let me know , how to write the command for xp_sendmail.
Thanks
August 16, 2006 at 6:31 am
Here is an example:
IF EXISTS (
SELECT * FROM some_table WHERE value LIKE value  
BEGIN
EXEC master..xp_sendmail @recipients = 'email_address',
@message = 'email message',
@copy_recipients = 'other_email',
@subject = 'Subject Title'
END
GO
August 16, 2006 at 4:40 pm
If checking for DB status, you may want to go that way:
SELECT DATABASEPROPERTYEX ('YourDB','STATUS')
Viewing 5 posts - 1 through 4 (of 4 total)
You must be logged in to reply to this topic. Login to reply