DBA,  Junior DBA

SQL server connection and blocking finding script

Advertisements

SQL server connection and blocking finding script

 

-- For SQL 2000
select db_name(dbid),* from master.dbo.sysprocesses where spid> 51 and status <>'sleeping' -- and blocked <>0


-- To find the spid and connections which are all running
select db_name (r.database_id),r.command,r.wait_resource,s.status,s.session_id,
r.blocking_session_id,r.last_wait_type,r.open_transaction_count,sql_handle,
* from sys.dm_exec_sessions s  join sys.dm_exec_requests r
on s.session_id =r.session_id 
--where s.status <>'sleeping'
and s.session_id >=51 
and s.session_id  <>@@SPID -- exclude your session

-- to find the blockings
select db_name (r.database_id),r.command,r.wait_resource,s.status,s.session_id,
r.blocking_session_id,r.last_wait_type,r.open_transaction_count, 
* from sys.dm_exec_sessions s join sys.dm_exec_requests r
on s.session_id =r.session_id 
where r.blocking_session_id<>0 -- list blocking

select *  FROM sys.dm_exec_requests

-- to find the code which is run by spid connections
SELECT T.TEXT As Query,
R.session_id,
R.status,
R.command
FROM sys.dm_exec_requests R
CROSS APPLY sys.dm_exec_sql_text(sql_handle) AS T
WHERE session_id = (54)

-- OR (going to be deprecated)

dbcc inputbuffer (52)

 

I’m currently working as a SQL server DBA in one of the top MNC. I’m passionate about SQL Server And I’m specialized in Administration and Performance tuning. I’m an active member of SQL server Central and MSDN forum. I also write articles in SQL server Central. For more Click here

Leave a Reply

Your email address will not be published. Required fields are marked *

WC Captcha 4 + 6 =

 hacklink panelweb shell downloadhacklink vozol 5000https://shoppuffer.com/https://vozol10000.com/
hacklink hacklink al hacklink panel hacklink hacklink panel hacklink al hack forum hacklink Shell download web shell download web shell archive web shell indir php shell download php shell archive php shell indir shell indir cami halısı cami halısı cami halısı cami halısı cami halısı cami halısı cami halısı cami halısı saricahali.com.tr cami halısı cami halısı cami halısı cami halısı cami avizesi cami avizesi cami süpürgesi cami süpürgesi cami ısıtma cami ısıtma evden eve nakliyat evden eve nakliyat evden eve nakliyat evden eve nakliyat ofis taşıma yurtiçi evden eve nakliyat yurtiçi evden eve nakliyat içel evden eve nakliyat seo hizmeti Rulet Casino Slot Oyna Bahigo 1xbet Deneme bonusu Bahis siteleri Maç özetleri Bahsegel Canlı Casino Siteleri Sweet Bonanza Blackjack Casino Rulet Oyna Canlı Casino istanbul escort muğla escort google.com.tr
hacklink
hacklink panel
hacklink al
hacklink
hacklink panel
hacklink al
deneme bonusu veren siteler