用SQl语句控制MS SQl server的用户连接

上一篇 / 下一篇  2006-06-13 00:00:00 / 个人分类:數據庫學習

create proc killspid (@dbname varchar(20))
as
begin
declare @sql nvarchar(500)
declare @spid int
set @sql='declare getspid cursor for
select spid from sysprocesses where dbid=db_id('''+@dbname+''')'
exec (@sql)
open getspid
fetch next from getspid into @spid
while @@fetch_status < >-1
begin
exec('kill '+@spid)
fetch next from getspid into @spid
end
close getspid
deallocate getspid
end

--用法
use master
exec killspid '数据库名'

TAG:

 

评分:0

我来说两句

显示全部

:loveliness: :handshake :victory: :funk: :time: :kiss: :call: :hug: :lol :'( :Q :L ;P :$ :P :o :@ :D :( :)

日历

« 2008-12-03  
 123456
78910111213
14151617181920
21222324252627
28293031   

数据统计

  • 访问量: 1663
  • 日志数: 416
  • 建立时间: 2007-12-11
  • 更新时间: 2008-03-06

RSS订阅

Open Toolbar