Solved

Alert Administrators to a blocking condition via email/SMS

Posted on 2004-04-30
4
237 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
ID: 10959756
0
 
LVL 34

Accepted Solution

by:
arbert earned 500 total points
ID: 10960538
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
ID: 10960549
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

What is SQL Server and how does it work?

The purpose of this paper is to provide you background on SQL Server. It’s your self-study guide for learning fundamentals. It includes both the history of SQL and its technical basics. Concepts and definitions will form the solid foundation of your future DBA expertise.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Having an SQL database can be a big investment for a small company. Hardware, setup and of course, the price of software all add up to a big bill that some companies may not be able to absorb.  Luckily, there is a free version SQL Express, but does …
JSON is being used more and more, besides XML, and you surely wanted to parse the data out into SQL instead of doing it in some Javascript. The below function in SQL Server can do the job for you, returning a quick table with the parsed data.
Familiarize people with the process of utilizing SQL Server functions from within Microsoft Access. Microsoft Access is a very powerful client/server development tool. One of the SQL Server objects that you can interact with from within Microsoft Ac…
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.

828 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