SqlServer强制断开数据库已有连接的方法(转)


在master数据库中执行如下代码

declare @i INT 
declare cur cursor for select spid from sysprocesses where db_name(dbid)= ''Your_Database_Name'  
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 


免责声明!

本站转载的文章为个人学习借鉴使用,本站对版权不负任何法律责任。如果侵犯了您的隐私权益,请联系本站邮箱yoyou2525@163.com删除。



 
粤ICP备18138465号  © 2018-2025 CODEPRJ.COM