快速排查SQL服务器阻塞语句

  SELECT*FROM sys.sysprocesses where spid> and blocked> --可以查看阻塞 

  SELECT SPID=p.spid, DBName =convert(CHAR(),d.name),  ProgramName =program_name, LoginName =convert(CHAR(),l.name), HostName =convert(CHAR(),hostname), Status= p.status, BlockedBy = p.blocked,LoginTime = login_time, QUERY =CAST(TEXT AS VARCHAR(MAX))
FROM MASTER.dbo.sysprocesses p
INNER JOIN MASTER.dbo.sysdatabases d ON p.dbid= d.dbid
INNER JOIN MASTER.dbo.syslogins l ON p.sid= l.sid
CROSS APPLY sys.dm_exec_sql_text(sql_handle) WHERE p.blocked =
AND EXISTS(SELECT FROM MASTER..sysprocesses p1 WHERE p1.blocked = p.spid) --可以查看阻塞的具体语句
上一篇:hdu 3333 树状数组+离线处理


下一篇:Java中对List集合的常用操作(转载)