本文整理自网络,侵删。
use master go
create proc KillSpByDbName(@dbname varchar(20))asbegindeclare @sql nvarchar(500),@temp varchar(1000)declare @spid intset @sql='declare getspid cursor for select spid from sysprocesses where dbid=db_id('''+@dbname+''')'exec (@sql)open getspidfetch next from getspid into @spidwhile @@fetch_status<>-1begin set @temp='kill '+rtrim(@spid) exec(@temp)fetch next from getspid into @spidendclose getspiddeallocate getspidend
Use master Exec KillSpByDbName '数据库名称'
相关阅读 >>
Delphi enablecontrols,disablecontrols函数
更多相关阅读请进入《Delphi》频道 >>