SQL Clone
SQLServerCentral is supported by Redgate
 
Log in  ::  Register  ::  Not logged in
 
 
 


Who's Blocking


Who's Blocking

Author
Message
Eric Wahner-345205
Eric Wahner-345205
SSC Journeyman
SSC Journeyman (94 reputation)SSC Journeyman (94 reputation)SSC Journeyman (94 reputation)SSC Journeyman (94 reputation)SSC Journeyman (94 reputation)SSC Journeyman (94 reputation)SSC Journeyman (94 reputation)SSC Journeyman (94 reputation)

Group: General Forum Members
Points: 94 Visits: 66
Comments posted to this topic are about the item Who's Blocking
DBA-640728
DBA-640728
Hall of Fame
Hall of Fame (3K reputation)Hall of Fame (3K reputation)Hall of Fame (3K reputation)Hall of Fame (3K reputation)Hall of Fame (3K reputation)Hall of Fame (3K reputation)Hall of Fame (3K reputation)Hall of Fame (3K reputation)

Group: General Forum Members
Points: 3023 Visits: 2000
i tried running this script , right click and click in output to text but i get this error

Msg 213, Level 16, State 7, Line 4
Insert Error: Column name or number of supplied values does not match table definition.
gperuch
gperuch
Forum Newbie
Forum Newbie (9 reputation)Forum Newbie (9 reputation)Forum Newbie (9 reputation)Forum Newbie (9 reputation)Forum Newbie (9 reputation)Forum Newbie (9 reputation)Forum Newbie (9 reputation)Forum Newbie (9 reputation)

Group: General Forum Members
Points: 9 Visits: 132
try this:

set nocount on
declare @spid varchar(10)
declare @blkby varchar(10)
declare @stmt varchar(100)

create table #temp
( spid integer, status varchar(100), login varchar(50), hostname varchar(25), blkby varchar(10),
dbname varchar(25), command varchar(100), cputime int, diskio int, lastbatch varchar(25),
programname varchar(255), spid2 int)
create table #temp2005
( spid integer, status varchar(100), login varchar(50), hostname varchar(25), blkby varchar(10),
dbname varchar(25), command varchar(100), cputime int, diskio int, lastbatch varchar(25),
programname varchar(255), spid2 int, requestid int)

if @@version like 'Microsoft SQL Server 2000%' insert into #temp exec sp_who2
if @@version like 'Microsoft SQL Server 2005%' insert into #temp2005 exec sp_who2

insert into #temp select spid, status ,login, hostname , blkby ,
dbname, command , cputime , diskio , lastbatch ,
programname , spid2 from #temp2005

declare curs cursor for
select convert(varchar(10),spid), blkby from #temp where blkby not like '%.%'

open curs

fetch next from curs into @spid, @blkby
while @@fetch_status = 0
begin
set @stmt = 'dbcc inputbuffer(' + @blkby + ')'
raiserror('SPID:%s is Blocking with the following statement',0,1,@blkby) with nowait
exec (@stmt)
raiserror('SPID that is Blocked:%s',0,1,@spid) with nowait
set @stmt = 'dbcc inputbuffer(' + convert(varchar(10), @spid) + ')'
exec (@stmt)
fetch next from curs into @spid, @blkby
end

close curs

deallocate curs

drop table #temp
drop table #temp2005
Go


Permissions

You can't post new topics.
You can't post topic replies.
You can't post new polls.
You can't post replies to polls.
You can't edit your own topics.
You can't delete your own topics.
You can't edit other topics.
You can't delete other topics.
You can't edit your own posts.
You can't edit other posts.
You can't delete your own posts.
You can't delete other posts.
You can't post events.
You can't edit your own events.
You can't edit other events.
You can't delete your own events.
You can't delete other events.
You can't send private messages.
You can't send emails.
You can read topics.
You can't vote in polls.
You can't upload attachments.
You can download attachments.
You can't post HTML code.
You can't edit HTML code.
You can't post IFCode.
You can't post JavaScript.
You can post emoticons.
You can't post or upload images.

Select a forum

































































































































































SQLServerCentral


Search