标签:ide proc processes objects gif 数据 dbid stat end
1 强制关闭数据库链接
--关闭用户打开的进程处理 USE master go IF EXISTS (SELECT * FROM dbo.sysobjects WHERE id = object_id(N‘[dbo].[p_killspid]‘) and OBJECTPROPERTY(id, N‘IsProcedure‘) = 1) DROP PROCEDURE [dbo].[p_killspid] go create proc p_killspid @dbname varchar(200) --要关闭进程的数据库名 as declare @programName nvarchar(200), @spid nvarchar(20) declare cDblogin cursor for select cast(spid as varchar(20)) AS spid from master..sysprocesses where dbid=db_id(@dbname) open cDblogin fetch next from cDblogin into @spid while @@fetch_status=0 begin --防止自己终止自己的进程 --否则会报错不能用KILL 来终止您自己的进程。 IF @spid <> @@SPID exec( ‘kill ‘+@spid) fetch next from cDblogin into @spid end close cDblogin deallocate cDblogin go --用法 exec p_killspid ‘fdoam‘
标签:ide proc processes objects gif 数据 dbid stat end
原文地址:http://www.cnblogs.com/zoumin123/p/7641832.html