Select sp_who2 into a temporary table
|
The following script is useful to filter down sp_who2 results. For example if you want to find all connections to one database you can add a where clause to the following query
CREATE TABLE ##temp_sp_who2 ( SPID INT, Status VARCHAR(1000) NULL, Login SYSNAME NULL, HostName SYSNAME NULL, BlkBy SYSNAME NULL, DBName SYSNAME NULL, Command VARCHAR(1000) NULL, CPUTime INT NULL, DiskIO INT NULL, LastBatch VARCHAR(1000) NULL, ProgramName VARCHAR(1000) NULL, SPID2 INT , rEQUESTID INT NULL --comment out for SQL 2000 databases ) INSERT INTO ##temp_sp_who2 EXEC sp_who2 SELECT * FROM ##temp_sp_who2 WHERE DBName = '<database_name>' DROP TABLE ##temp_sp_who2
No comments:
Post a Comment