This question SQL Server: Filter output of sp_who2 has a method to insert the result of sp_who2 into a table.
How can I insert the result into a table in addition to a timestamp for the insert.
drop table if exists #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,
te4xt varchar(250)
)
GO
INSERT INTO #sp_who2
EXEC sp_who2
GO