Simple question I couldn\'t figure out (not a SQL expert... sorry): I want to do a select on the result set of sp_who2. How can I?
for ex. select SPID from [result set f
Use a loopback query like this
SELECT SPID, Status, Login, HostName, BlkBy,DBName,
Command, CPUTime, DiskIO, LastBatch, ProgramName
INTO #TempSpWho2
FROM OPENROWSET ('SQLOLEDB','Server=(local);TRUSTED_CONNECTION=YES;',
'set fmtonly off exec master.dbo.sp_who2')
SELECT * FROM #TempSpWho2
see also Store The Output Of A Stored Procedure In A Table Without Creating A Table
on SQL Server 2005 and up use sys.dm_exec_sessions and sys.dm_exec_requests