/*
关闭用户打开的进程处理
*/
use master
goif exists (select * from dbo.sysobjects where id = object_id(N'[dbo].[p_killspid]') and OBJECTPROPERTY(id, N'IsProcedure') = 1)
drop procedure [dbo].[p_killspid]
GOcreate proc p_killspid
@dbname varchar(200) --要关闭进程的数据库名
as  
declare @sql  nvarchar(500)  
declare @spid nvarchar(20) declare #tb cursor for
select spid=cast(spid as varchar(20)) from master..sysprocesses where dbid=db_id(@dbname)
open #tb
fetch next from #tb into @spid
while @@fetch_status=0
begin  
exec('kill '+@spid)
fetch next from #tb into @spid
end  
close #tb
deallocate #tb
go--用法  
exec p_killspid  '数据库名'

解决方案 »

  1.   

    你的数据库连接最好是打开master数据库。
      

  2.   

    解释一下,在办公室,是公用网,有时能进,有时不能进。在家,用的是ADSL,安装的是XP,一进管理就死机。看来晚上下班后得把Win2000鬼出来。现在问题解决了,在大家的帮助下。心情很好,基层又可以轻松了。放点Music guita 出来听。请别怪,马可的名字好独特,历史上联想到丝绸之路,人物长像上联想到爱德蒙当代斯(基督山伯爵)。Very happy and glad to have so many good fellows as you. Pardon, please. Sometimes I found it very difficult to type Chinese words. So the English always come out before I know. If you agree, let's communicate in English from time to time. What is your idea, BaoBao?