Solved

Alert Administrators to a blocking condition via email/SMS

Posted on 2004-04-30
4
218 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

When you hear the word proxy, you may become apprehensive. This article will help you to understand Proxy and when it is useful. Let's talk Proxy for SQL Server. (Not in terms of Internet access.) Typically, you'll run into this type of problem w…
This article explains how to reset the password of the sa account on a Microsoft SQL Server.  The steps in this article work in SQL 2005, 2008, 2008 R2, 2012, 2014 and 2016.
Via a live example, show how to set up a backup for SQL Server using a Maintenance Plan and how to schedule the job into SQL Server Agent.
Via a live example, show how to setup several different housekeeping processes for a SQL Server.

911 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

21 Experts available now in Live!

Get 1:1 Help Now