SQL Server Forums
Profile | Register | Active Topics | Members | Search | Forum FAQ
 
Register Now and get your question answered!
Username:
Password:
Save Password
Forgot your Password?

 All Forums
 General SQL Server Forums
 Script Library
 Show Lead Blockers
 New Topic  Reply to Topic
 Printer Friendly
Author Previous Topic Topic Next Topic  

scottpt
Posting Yak Master

USA
186 Posts

Posted - 01/29/2004 :  13:08:51  Show Profile  Reply with Quote
/*******************************************************************************
**
** This script will show you the lead blockers and all blocked processes.
**
**
*********************************************************************************/


set nocount on
SELECT spid,blocked,sd.name 'database',sl.name 'login',hostname,program_name
INTO #blocks
FROM master..sysprocesses sp
inner join sysxlogins sl
on sp.sid=sl.sid
inner join sysdatabases sd
on sp.dbid=sd.dbid
WHERE blocked <> 0


Print 'Lead Blockers'
print '============================================================================================='
SELECT sp.spid,sp.blocked,sd.name 'database',sl.name 'login',sp.hostname,sp.program_name
FROM master..sysprocesses sp
inner join sysxlogins sl
on sp.sid=sl.sid
inner join sysdatabases sd
on sp.dbid=sd.dbid
inner join #blocks b
on b.blocked=sp.spid
and sp.blocked=0

Print 'Blocked'
print '============================================================================================='
Select * from #blocks

drop table #blocks
  Previous Topic Topic Next Topic  
 New Topic  Reply to Topic
 Printer Friendly
Jump To:
SQL Server Forums © 2000-2009 SQLTeam Publishing, LLC Go To Top Of Page
This page was generated in 0.06 seconds. Powered By: Snitz Forums 2000