標籤:
--當很多串連到你的資料庫時,報這種錯誤“已超過了鎖請求逾時時段”
--直接把下在面的預存程序 放到你的Master資料庫執行一下就可以了
1 USE pratice 2 SET ANSI_NULLS ON 3 SET QUOTED_IDENTIFIER ON 4 go 5 6 create PROC [dbo].[Sp_KillAllProcessInDB] @DbName VARCHAR(100) 7 AS 8 IF DB_ID(@DbName) = NULL 9 BEGIN10 PRINT ‘DataBase dose not Exist‘11 END12 ELSE13 BEGIN14 DECLARE @killspId VARCHAR(30)15 DECLARE TmpCursor CURSOR16 FOR17 SELECT ‘Kill ‘ + CONVERT(VARCHAR, spid) AS spId18 FROM master..SysProcesses19 WHERE DB_NAME(dbid) = @DbName20 AND spid <> @@spid --終止不是當前進程的進程(不等於當前進程)21 AND dbid <> 0 --資料庫ID不是022 OPEN TmpCursor23 FETCH NEXT FROM TmpCursor24 25 INTO @killspId --select into @killspId26 WHILE @@FETCH_STATUS = 027 BEGIN28 EXEC (@killspId)29 FETCH NEXT FROM TmpCursor30 INTO @killspId31 32 END33 34 CLOSE TmpCursor35 DEALLOCATE TmpCursor36 END37 38 exec Sp_KillAllProcessInDB ‘要訪問的資料庫‘
(以上轉載來自:http://www.cnblogs.com/lyhabc/articles/3235601.html)
查看鎖定的進程ID
SELECT blocking_session_id ‘阻塞進程的ID‘, wait_duration_ms ‘等待時間(毫秒)‘, session_id ‘(會話ID)‘ FROM sys.dm_os_waiting_tasks
SQL SERVER錯誤:已超過了鎖請求逾時時段。 (Microsoft SQL Server,錯誤: 1222) 解決方案