Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations SkipVought on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Send Mail When Blocking Occurs

Status
Not open for further replies.
Jun 29, 2001
195
0
0
US
Need to setup a job to check sysprocesses and send email when blocked > 0

TIA

Ashley L Rickards
SQL DBA
 
Something like this:


select blocked from dbo.sysprocesses -- where blocked > 0
IF sysprocesses.BLOCKED > 0

EXEC xp_sendmail @recipients = 'user@company.com',
@query = 'Select * from sysprocesses where blocked > 0',
@message = 'Processes are blocked on IPDOCKET01',
@subject = 'Processes are BLOCKED',
@attach_results = 'TRUE'



Ashley L Rickards
SQL DBA
 
I'm not sure using jobs + xp_sendmail is the right way to monitor problematic DB activity. Try with alerts instead (Type: SQL Server performance condition alert, Object: servername/Locks).

 
That might capture it .. I'm trying to track some bad code which is causing networkio so I need something more custom.

Ashley L Rickards
SQL DBA
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top