日期:2014-05-18 浏览次数:20623 次
USE [master] GO /****** Object: StoredProcedure [dbo].[Sp_KillAllProcessInDB] Script Date: 05/11/2012 20:55:55 ******/ SET ANSI_NULLS ON GO SET QUOTED_IDENTIFIER ON GO create Proc [dbo].[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 先创建这个存储过程 然后 执行 exec Sp_KillAllProcessInDB '你的库名' 就可以KILL所有链接了。 然后你就具有独霸权限了。想怎么操作怎么操作。