use master go declare @table table( spid int, status varchar(max), login varchar(max), hostname varchar(max), blkby varchar(max), dbname varchar(max), command varchar(max), cputime int, diskio int, lastbatch varchar(max), programname varchar(max), spid_1 int, requestid int ) insert into @table exec sp_who2 select * from @table where dbname = 'NCRWO_Transactions'