Delphi 关闭SQL Server 数据库所有使用连接


本文整理自网络,侵删。

 
use master  
go

create proc KillSpByDbName(@dbname varchar(20))
as
begin
declare @sql nvarchar(500),@temp varchar(1000)
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
 set @temp='kill '+rtrim(@spid)
 exec(@temp)
fetch next from getspid into @spid
end
close getspid
deallocate getspid
end

Use master   
 Exec KillSpByDbName '数据库名称'

相关阅读 >>

Delphi 关于虚拟的desktop的编程

Delphi adoquery1数据表参数调用

Delphi concat 字符串函数

Delphi 获取标题栏高

Delphi xe7 ios 取得系统字型名称

Delphi dll创建并调用

Delphi获取文件创建时间、文件最后修改时间

Delphi修改资源文件的代码

Delphi listboxadditems() 不重复添加edit1

Delphi 比较两个日期是否大于n天

更多相关阅读请进入《Delphi》频道 >>



打赏

取消

感谢您的支持,我会继续努力的!

扫码支持
扫码打赏,您说多少就多少

打开支付宝扫一扫,即可进行扫码打赏哦

分享从这里开始,精彩与您同在

评论

管理员已关闭评论功能...