查找阻塞


SELECT
             s.spid, BlockingSPID 
=  s.blocked, DatabaseName  =   DB_NAME (s.dbid),
             s.program_name, s.loginame, ObjectName 
=   OBJECT_NAME (objectid,                      s.dbid), Definition  =   CAST ( text   AS   VARCHAR ( MAX ))
 
INTO         #Processes
 
FROM       sys.sysprocesses s  -- where s.spid=1300
  CROSS  APPLY sys.dm_exec_sql_text (sql_handle)
 
WHERE  s.spid  > 50

select   * From  #processes  where  blockingspid <> 0

 

你可能感兴趣的:(阻塞)