select distinct s.spid, session_id,s.blocked, db_name(database_id) db,s.loginame,s.hostname,start_time,a.status,command,wait_type,
last_wait_type,wait_time,cpu_time,total_elapsed_time,writes,logical_reads + reads IORead,t.physical_io,t.threads,b.text 
from sys.sysprocesses s inner join sys.dm_exec_requests  a on a.session_id=s.spid cross apply sys.dm_exec_sql_text(a.sql_handle) b  
left join (
	select spid,sum(physical_io )physical_io,COUNT(1) threads
	from sys.sysprocesses where spid in (
	select spid
	from sys.sysprocesses 
  ) and spid>50
group by spid ) t on s.spid=t.spid
where session_id>50  
--and db_name(database_id)='SMS'
--and loginame='BReport'
order by start_time

  

 

posted on 2025-06-07 21:38  timy  阅读(5)  评论(0)    收藏  举报