Jasinski Technical Wiki

Navigation

Home Page
Index
All Pages

Quick Search
»
Advanced Search »

Contributor Links

Create a new Page
Administration
File Management
Login/Logout
Your Profile

Other Wiki Sections

Software

PoweredBy

sp_who2 with Filtered Results - SQL Server

RSS
Modified on Fri, Sep 07, 2012, 12:06 PM by Administrator Categorized as SQL Server
if OBJECT_ID(N'tempdb..#who') is not null drop table #who

create table #who (
     SPID           int
    ,[Status]       varchar(20)
    ,[Login]        nvarchar(300)
    ,HostName       nvarchar(300)
    ,BlkBy          nvarchar(300)
    ,DbName         nvarchar(300)
    ,Command        nvarchar(4000)
    ,CPUTime        int
    ,DiskIO         int
    ,LastBatch      varchar(20)
    ,ProgramName    nvarchar(300)
    ,SPID2          int
    ,REQUESTID      int
    )
    
insert into #who exec sp_who2

select * from #who where DbName = 'MyDatabase'

ScrewTurn Wiki version 3.0.1.400. Some of the icons created by FamFamFam. Except where noted, all contents Copyright © 1999-2018, Patrick Jasinski.