Solved

Alert Administrators to a blocking condition via email/SMS

Posted on 2004-04-30
4
205 Views
Last Modified: 2010-05-18
Occasionally (once every couple of months) the database we use (MS SQL 2000) suffers from blocking. When a block occurs, manual intervention is often necessary to sort the problem out. The blocks cause huge problems for users of the system until they are cleared.

Does anybody know whether it is possible to create an application/stored procedure etc to check whether blocking exists and send an email and SMS to an administrator?

Any help would be greatly appreciated.

TIA

James
0
Comment
Question by:JamesAStewart
  • 2
4 Comments
 
LVL 6

Expert Comment

by:lausz
Comment Utility
0
 
LVL 34

Accepted Solution

by:
arbert earned 500 total points
Comment Utility
This can be modified for your use:






create table #block (
spid int,
ecid int,
status varchar(255),
loginname varchar(255),
hostname varchar(255),
blocking int,
dbname varchar(255),
command varchar(255)
)

insert into #block
exec sp_who

select * from #block
where blocking>0

if @@rowcount>0
begin
exec   master..xp_sendmail @recipients='archerb',
               @query='sp_who',@attach_results='true',@subject='BLOCKING!!!'

end

drop table #block
0
 
LVL 34

Expert Comment

by:arbert
Comment Utility
Just schedule the above script to run however often you need it to--every 5minutes or so, it shouldn't use too many resources....
0

Featured Post

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.

Join & Write a Comment

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.
Ever wondered why sometimes your SQL Server is slow or unresponsive with connections spiking up but by the time you go in, all is well? The following article will show you how to install and configure a SQL job that will send you email alerts includ…
This video shows how to set up a shell script to accept a positional parameter when called, pass that to a SQL script, accept the output from the statement back and then manipulate it in the Shell.
Viewers will learn how the fundamental information of how to create a table.

743 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

17 Experts available now in Live!

Get 1:1 Help Now