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'
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 update #who set BlkBy = '0' where BlkBy = ' .' select * from #who where DbName = 'MyDatabase' and (BlkBy <> '0' or Spid in (select BlkBy from #who))
ScrewTurn Wiki version 3.0.1.400. Some of the icons created by FamFamFam. Except where noted, all contents Copyright © 1999-2024, Patrick Jasinski.