已超过了锁请求超时时段、杀掉相应数据库的进程、数据库强制还原 的方法

 1 Create Proc Sp_KillAllProcessInDB 
 2 
 3 @DbName VarChar(100)
 4 
 5 as
 6 if db_id(@DbName= Null 
 7 begin
 8 Print 'DataBase dose not Exist'
 9 end
10 else
11 
12 Begin
13 Declare @spId Varchar(30)
14 
15 DECLARE TmpCursor CURSOR FOR
16 Select 'Kill ' + convert(Varchar, spid) as spId
17 from master..SysProcesses
18 where db_Name(dbID) = @DbName
19 and spId <> @@SpId
20 and dbID <> 0
21 OPEN TmpCursor
22 
23 FETCH NEXT FROM TmpCursor
24 INTO @spId 
25 
26 WHILE @@FETCH_STATUS = 0
27 
28 BEGIN
29 
30 Exec (@spId)
31 
32 FETCH NEXT FROM TmpCursor
33 INTO @spId 
34 
35 END
36 
37 
38 CLOSE TmpCursor
39 DEALLOCATE TmpCursor
40 
41 end 
42 
43 GO
44 --To Execute
45 Exec dbo.Sp_KillAllProcessInDB 'DBname'

摘自:http://www.cnblogs.com/LCX/archive/2008/12/03/1346924.html

原文地址:https://www.cnblogs.com/haoliansheng/p/1712692.html