Return to Snippet

Revision: 29910
at August 5, 2010 02:47 by SDWenzel


Initial Code
DECLARE @DBNm varchar(50)

SET @DBNm = 'CPDB_%'

SELECT  d.name AS DBNm
       ,p.hostname
       ,convert(sysname, rtrim(p.loginame)) as loginname
       ,p.program_name
       ,  substring(convert(varchar,p.last_batch,111) ,6  ,5 ) + ' '
        + substring(convert(varchar,p.last_batch,113) ,13 ,8 )
             as 'last_batch_char'
       ,p.blocked
       ,p.spid
       ,p.waittime
       ,p.waittype
       ,ctrl.dbo.fnWaitType(p.waittype, 'Dsc') AS WaitTypeDsc
       ,p.cmd
       ,p.status
--       ,p.sid
--       ,p.cpu
--       ,p.physical_io
--       ,p.dbid
--       ,*
 FROM Master.dbo.sysProcesses p  (nolock)
 LEFT JOIN Master.dbo.sysDatabases d ON d.DBId = p.DBId
WHERE d.Name LIKE @DBNm
ORDER BY d.name

Initial URL

                                

Initial Description

                                

Initial Title
sp_Who Functionality Filtered by Database Name

Initial Tags

                                

Initial Language
SQL