Capture sp_who2
USE: To capture the result from executing sp_who2 system stored procedure.
SET NOCOUNT ON IF OBJECT_ID('tempdb..#SP_WHO2') IS NOT NULL DROP TABLE #SP_WHO2 GO CREATE TABLE #SP_WHO2 ( SPID varchar(128) , [Status] char(12) , [Login] varchar(128) , [HostName] varchar(128) , [BlkBy] varchar(128) , [DBName] varchar(128) , [Command] varchar(128) , [CPUTime] varchar(128) , [DiskIO] varchar(128) , LastBatch varchar(128) , ProgramName varchar(128) , SPID2 varchar(128) , REQUESTED varchar(128)) INSERT #SP_WHO2 EXEC SP_WHO2 GO