断开数据库连接的两种方法
作者:[51ak ]
SELECT * FROM SYS.DATABASES
方法一:
USE master
DECLARE @spid varchar(20)
DECLARE CUR CURSOR
FOR SELECT spid FROM sysprocesses WHERE dbid = 5
open CUR
FETCH NEXT FROM CUR INTO @spid
WHILE @@FETCH_STATUS = 0
BEGIN
print 'KILL ' + @spid
EXEC ('KILL ' + @spid )
FETCH NEXT FROM CUR INTO @spid
END
CLOSE CUR
DEALLOCATE CUR
方法二: