当前位置: 数据库>sqlserver
sqlserver下Kill 所有连接到某一数据库的连接
来源: 互联网 发布时间:2014-09-05
本文导语: 代码如下:USE masterDECLARE @spid intDECLARE CUR CURSORFOR SELECT spid FROM sysprocesses WHERE dbid = 5FETCH NEXT FROM CUR INTO @spidWHILE @@FETCH_STATUS = 0BEGIN--EXEC ('KILL ' + @spid )FETCH NEXT FROM CUR INTO @spidENDCLOSE CURDEALLOCATE CUR