-- What users are active db x?
USE master
GO
IF OBJECT_ID('tempdb..#dbSPIDS') IS NOT NULL DROP TABLE #dbSPIDS
CREATE TABLE #dbSPIDS (
SPID INT
, [Status] VARCHAR (256)
, [Login] VARCHAR (256)
, HostName VARCHAR (256)
, BlkBy VARCHAR (256)
, DBName VARCHAR (256)
, Command VARCHAR (MAX)
, CPUTime INT
, DiskIO INT
, LastBatch VARCHAR (256)
, ProgramName VARCHAR (256)
, SPID2 INT
, REQUESTID INT
)
INSERT #dbSPIDS EXEC sp_who2
-- SELECT d.*
SELECT 'KILL ', d.SPID, d.*
FROM #dbSPIDS d
where login not like '%sa%'
-- WHERE d.dbname LIKE '%MyDB%dnn%TMAR'
--WHERE d.dbname = 'MyDB-d-TMAR'
-- and (d.dbname LIKE 'MyDBTMAR' OR d.dbname LIKE 'MyDBTMAR_new' )
and (d.dbname LIKE '%760%' )
-- kill 54
No comments:
Post a Comment