查找堵塞
--查找堵塞源 SELECT * FROM master.sys.sysprocesses WHERE SPID>50 and blocked!=0 order by waittime desc --堵塞源的堵塞类型 SELECT CASE WHEN waittime!=0X0000 AND open_tran>=0 AND status='runnable' THEN N'运行时间太长' WHEN waittime=0X0000 AND open_tran>0 AND status='sleeping' THEN N'sleeping进程事物未提交' WHEN waittime in(0x0800,0x0063) AND open_tran>=0 AND status='runnable' THEN N'没有及时取走结果集' WHEN waittime=0X0000 AND open_tran>0 AND status='rollback' THEN N'超时或主动回滚' WHEN waittime>=0X0000 AND open_tran>=0 AND status='runnable' THEN N'死锁以堵塞体现' END AS Reason, b.text SQL,program_name,hostname,loginame FROM master.sys.sysprocesses a CROSS APPLY sys.dm_exec_sql_text(a.sql_handle) b WHERE SPID=57