码迷,mamicode.com
首页 > 数据库 > 详细

解决SQLSERVER数据库表被琐死!

时间:2014-07-19 17:02:00      阅读:201      评论:0      收藏:0      [点我收藏+]

标签:style   blog   color   os   数据   for   

--杀死全部锁死进程
ALTER Proc Sp_KillAllProcessInDB
@DbName VarChar(100)
as
if db_id(@DbName= Null
begin
Print DataBase dose not Exist
end
else
 
Begin
Declare @spId Varchar(30)
 
DECLARE TmpCursor CURSOR FOR
Select Kill  + convert(Varchar, spid) as spId
from master..SysProcesses
where db_Name(dbID) = @DbName
and spId <> @@SpId
and dbID <> 0
OPEN TmpCursor
 
FETCH NEXT FROM TmpCursor
INTO @spId
 
WHILE @@FETCH_STATUS = 0
 
BEGIN
 
Exec (@spId)
 
FETCH NEXT FROM TmpCursor
INTO @spId
 
END
 
 
CLOSE TmpCursor
DEALLOCATE TmpCursor
 
end
 
GO
--To Execute
Exec dbo.Sp_KillAllProcessInDB 数据库名

解决SQLSERVER数据库表被琐死!,布布扣,bubuko.com

解决SQLSERVER数据库表被琐死!

标签:style   blog   color   os   数据   for   

原文地址:http://www.cnblogs.com/zhuiyi/p/3854017.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!