当前位置:Gxlcms > mssql > sqlserver下Kill所有连接到某一数据库的连接

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

时间:2021-07-01 10:21:17 帮助过:97人阅读

代码如下:

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

您可能感兴趣的文章:

  • sqlserver进程死锁关闭的方法
  • SqlServer查询和Kill进程死锁的语句

人气教程排行