2023-08-07 10:20:32 +02:00

36 lines
1001 B
SQL

select [Process ID] = p.spid,
[User] = case when p.spid > 6
then convert(sysname, ISNULL(suser_sname(p.sid), rtrim(p.nt_domain) + '\' + rtrim(p.nt_username)))
else 'system'
end,
p.dbid as DB_ID,
[Database] = case when p.dbid = 0
then 'no database context'
else db_name(p.dbid)
end,
[Status] = p.status,
[Open Transactions] = p.open_tran,
[Command] = p.cmd,
[Application] = p.program_name,
[Wait Time] = p.waittime,
[Wait Type] = case when p.waittype = 0
then 'not waiting'
else p.lastwaittype
end,
[Wait Resource] = case when p.waittype = 0
then ''
else p.waitresource
end,
[CPU] = p.cpu,
[Physical IO] = p.physical_io,
[Memory Usage] = p.memusage,
[Login Time] = p.login_time,
[Last Batch] = p.last_batch,
[Host] = p.hostname,
[Net Library] = p.net_library,
[Net Address] = p.net_address,
[Blocked By] = p.blocked,
[Blocking] = 0,
[Execution Context ID] = p.ecid
from master.dbo.sysprocesses p with (NOLOCK) where p.dbid NOT IN (0,1,14)
order by p.login_time desc