USE master;
GO
DECLARE @SQL VARCHAR(MAX);
SET @SQL=''
SELECT @SQL=@SQL+'; KILL '+RTRIM(SPID)
FROM master..sysprocesses
WHERE dbid=DB_ID('ty_active_log_gz');
EXEC(@SQL);
GO
ALTER DATABASE ty_active_log_gz SET MULTI_USER;
USE master;
GO
DECLARE @SQL VARCHAR(MAX);
SET @SQL=''
SELECT @SQL=@SQL+'; KILL '+RTRIM(SPID)
FROM master..sysprocesses
WHERE dbid=DB_ID('ty_active_log_gz');
EXEC(@SQL);
GO
ALTER DATABASE ty_active_log_gz SET MULTI_USER;