首页 > 代码库 > 用户量过大,防止数据库死锁

用户量过大,防止数据库死锁


use master

Create Procedure dbo.spKillLockS
as
declare @spid varchar(10)
DECLARE Abc CURSOR FOR
select spid --‘死锁的进程‘
from master..sysprocesses a join (
select blocked from master..sysprocesses group by blocked
)b on a.spid=b.blocked where
a.dbid=db_id(‘FumaCRM8‘) and a.blocked=0
Open Abc
FETCH NEXT FROM Abc INTO @spid
WHILE (@@FETCH_STATUS = 0)
BEGIN
exec(‘kill ‘+@spid)
FETCH NEXT FROM Abc INTO @spid
END
close Abc
DEALLOCATE Abc

用户量过大,防止数据库死锁