--断开指定库的所有用户连接(在master数据库中进行) use master goif exists (select * from dbo.sysobjects where id = object_id(N'[dbo].[sp_KillSpid]') and OBJECTPROPERTY(id, N'IsProcedure') = 1) drop procedure [dbo].[sp_KillSpid] GOcreate proc sp_KillSpid @dbname sysname --要断开连接的数据库名 as declare @s nvarchar(1000) declare tb cursor local for select N'kill '+cast(spid as varchar) from master..sysprocesses where dbid=db_id(@dbname)open tb fetch next from tb into @s while @@fetch_status=0 begin exec(@s) fetch next from tb into @s end close tb deallocate tb go--调用 exec sp_KillSpid 'aa'
use master
goif exists (select * from dbo.sysobjects where id = object_id(N'[dbo].[sp_KillSpid]') and OBJECTPROPERTY(id, N'IsProcedure') = 1)
drop procedure [dbo].[sp_KillSpid]
GOcreate proc sp_KillSpid
@dbname sysname --要断开连接的数据库名
as
declare @s nvarchar(1000)
declare tb cursor local
for
select N'kill '+cast(spid as varchar)
from master..sysprocesses
where dbid=db_id(@dbname)open tb
fetch next from tb into @s
while @@fetch_status=0
begin
exec(@s)
fetch next from tb into @s
end
close tb
deallocate tb
go--调用
exec sp_KillSpid 'aa'
http://community.csdn.net/Expert/topic/4797/4797198.xml?temp=.8292505
不知道小弟在上面说的问题有没有得罪到大哥!这个sp_KillSpid 过程我怎么在联机向导中找不到呢?利剑多有得罪 请大哥见谅!
我今年大2,经老师推荐给学校做一管理系统,现在就剩最后的工作了(数据导出导入和远程备份)!
所以在那里气愤的对大哥的书做了点评价,不知道大哥有没有生气!可不要以后不回我的帖子啊!
中国的年轻一代还是要靠您的指点! 最后利剑谢谢大哥!
郁闷自己啊