sqlserver下Kill 所有连接到某一数据库的连接
程序员文章站
2023-12-10 15:20:52
复制代码 代码如下:use masterdeclare @spid intdeclare cur cursorfor select spid from sysprocess...
复制代码 代码如下:
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