解决方法
1. 要想确定某项阻塞的根本原因,首先要确定是哪个SPID造成了阻塞。
2. 如果有多个SPID参与在某项阻塞中,那么必须找到主要的阻塞进程。
o 在SLQ Server Management Studio中运行sp_who或sp_who2以便找出主要的阻塞进程。
o 或者, SQL内的活动监视程序也能提供这项信息。
3. 一旦找到主要的阻塞进程之后,请在SQL Server Management Studio内运行以下查询:
SELECT
(SELECT [text]
FROM sys.dm_exec_sql_text(sql_handle)
) AS SqlCommand,
spid AS [Process ID], status AS [Status],
hostname AS [Host Name], hostprocess AS [Host Process], SPACE(3) AS [Company],
0 AS [Task], SPACE(64) AS [Description],
loginame AS [User], open_tran AS [Open Trans], cmd AS [Command],
blocked AS [Blocked], CONVERT(VARCHAR(19), waittime) AS [Wait Time],
[Waiting] =
Case waittype
WHEN 0x0000 THEN SPACE(256)
Else waitresource
END, login_time AS [Login Time],
SPACE(64) AS [WTS Client], SPACE(12) AS [WTS ID],
program_name AS [Application]
FROM sys.sysprocesses WITH (NOLOCK)
WHERE
spid = ##