SQL Server – querying active users by database

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'

Leave a Reply

Your email address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.