Friday, 10 July 2009

How to filter sp_who2 information

DECLARE @sp_who2 TABLE 
(
SPID INT,
Status VARCHAR(255) NULL,
Login SYSNAME NULL,
HostName SYSNAME NULL,
BlkBy SYSNAME NULL,
DBName SYSNAME NULL,
Command VARCHAR(255) NULL,
CPUTime INT NULL,
DiskIO INT NULL,
LastBatch VARCHAR(255) NULL,
ProgramName VARCHAR(255) NULL,
SPID2 INT,
REQUESTID INT
)

INSERT @sp_who2 EXEC sp_who2

SELECT * FROM @sp_who2
WHERE Status > 'BACKGROUND'

No comments:

Post a Comment