sqlserver 关闭所有连接
USE MASTER
DECLARE @i INT
SELECT @i=1
DECLARE @sSPID VARCHAR(100)
DECLARE KILL_CUR SCROLL CURSOR FOR
SELECT SPID FROM sysprocesses WHERE DBID=DB_ID('数据库名')
OPEN KILL_CUR
IF @@CURSOR_ROWS=0 GOTO END_KILL_CUR
FETCH FIRST FROM KILL_CUR INTO @sSPID
EXEC('KILL '+@sSPID)
PRINT @sSPID
WHILE @i<@@CURSOR_ROWS
BEGIN
FETCH NEXT FROM KILL_CUR INTO @sSPID
EXEC('KILL '+@sSPID)
PRINT @sSPID
SELECT @i=@i+1
END
END_KILL_CUR:
CLOSE KILL_CUR
DEALLOCATE KILL_CUR