1 Create Proc Sp_KillAllProcessInDB 
2
3 @DbName VarChar(100)
4
5 as
6
7 if db_id(@DbName) = Null
8
9 begin
10
11 Print 'DataBase dose not Exist'
12
13 end
14
15 else
16
17
18 Begin
19
20 Declare @spId Varchar(30)
21
22
23 DECLARE TmpCursor CURSOR FOR
24
25 Select 'Kill ' + convert(Varchar, spid) as spId
26
27 from master..SysProcesses
28
29 where db_Name(dbID) = @DbName
30
31 and spId <> @@SpId
32
33 and dbID <> 0
34
35 OPEN TmpCursor
36
37
38 FETCH NEXT FROM TmpCursor
39
40 INTO @spId
41
42
43 WHILE @@FETCH_STATUS = 0
44
45
46
47 BEGIN
48
49
50
51 Exec (@spId)
52
53
54 FETCH NEXT FROM TmpCursor
55
56 INTO @spId
57
58
59 END
60
61
62 CLOSE TmpCursor
63
64 DEALLOCATE TmpCursor
65
66
67
68 end
69
70
71
72 GO

  Exec dbo.Sp_KillAllProcessInDB 'DBName'

kill数据库死锁进程

相关文章:

  • 2022-12-23
  • 2022-03-08
  • 2022-12-23
  • 2022-03-02
  • 2022-12-23
  • 2021-09-10
  • 2021-09-12
  • 2022-01-24
猜你喜欢
  • 2021-10-10
  • 2021-10-05
  • 2022-12-23
  • 2022-12-23
  • 2022-02-27
相关资源
相似解决方案