用管理员账户sa登陆,然后在master下新建查询:

declare @i int declare cur cursor for select spid from sysprocesses where db_name(dbid)= '要断开连接的数据库名称' open cur fetch next from cur into @i while @@fetch_status=0 begin exec('kill '+@i) fetch next from cur into @i end close cur deallocate cur 

 

 

 

参考:

https://blog.csdn.net/jiankunking/article/details/44352033

posted on 2020-01-07 10:28  小油2018  阅读(695)  评论(0)    收藏  举报