SELECT spid, DB_NAME(dbid) AS DBName,cpu, memusage, login_time,
loginame, hostname, client_net_address
FROM master.sys.dm_exec_connections ec
inner join master.dbo.sysprocesses sp on sp.spid = ec.session_id
where DB_NAME(dbid) ='DatabaseName'
group by spid, DB_NAME(dbid),cpu, memusage, login_time,
loginame, hostname, client_net_address
ORDER BY cpu desc, DB_NAME(dbid)
Comments