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


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

posted @ 2014-10-24 11:23  随情  阅读(272)  评论(0编辑  收藏  举报