Wednesday, March 13, 2013

SQL Server sp_who2 how to order


--sp_who2

DROP TABLE #sp_who2

CREATE TABLE #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)

GO
INSERT INTO #sp_who2
EXEC sp_who2

SELECT * FROM #sp_who2 ORDER BY DiskIO DESC
Post a Comment