SQL Server Forums
Profile | Register | Active Topics | Members | Search | Forum FAQ
 
Register Now and get your question answered!
Username:
Password:
Save Password
Forgot your Password?

 All Forums
 General SQL Server Forums
 Script Library
 Quick 'n' dirty sp_who2 enhancement
 New Topic  Reply to Topic
 Printer Friendly
Author Previous Topic Topic Next Topic  

PABluesMan
Starting Member

26 Posts

Posted - 03/25/2008 :  16:01:41  Show Profile  Reply with Quote
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
  Previous Topic Topic Next Topic  
 New Topic  Reply to Topic
 Printer Friendly
Jump To:
SQL Server Forums © 2000-2009 SQLTeam Publishing, LLC Go To Top Of Page
This page was generated in 0.03 seconds. Powered By: Snitz Forums 2000