Please start any new threads on our new site at https://forums.sqlteam.com. We've got lots of great SQL Server experts to answer whatever question you can come up with.

 All Forums
 General SQL Server Forums
 Script Library
 Quick 'n' dirty sp_who2 enhancement

Author  Topic 

PABluesMan
Starting Member

26 Posts

Posted - 2008-03-25 : 16:01:41
Here's a quick script to filter the system SPIDs out of the result set from sp_who2. Enjoy!

/*********************************************************************************************************/
CREATE TABLE #Who (
SPID INT,
Status VARCHAR (128),
Login VARCHAR (256),
HostName VARCHAR (128),
BlkBy VARCHAR (8),
DBName VARCHAR (128),
Command VARCHAR (128),
CPUTime INT,
DiskIO INT,
LastBatch VARCHAR (32),
ProgramName VARCHAR (1024),
SPID2 INT,
RequestID INT
)

INSERT #Who
EXEC sp_who2

SELECT *
FROM #Who
WHERE SPID > 50
order by login

DROP TABLE #Who
/*********************************************************************************************************/


I geek, therefore I am
   

- Advertisement -