sqlserver下Kill 所有连接到某一数据库的连接

复制代码 代码如下:

use master

declare @spid int

declare cur cursor

for select spid from sysprocesses where dbid = 5

fetch next from cur into @spid

while @@fetch_status = 0

begin

–exec (‘kill ‘ + @spid )

fetch next from cur into @spid

end

close cur

deallocate cur

(0)
上一篇 2022年3月21日
下一篇 2022年3月21日

相关推荐