Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- select count(*) as Cpus,
- sum(IsIdle) + 1 as IdleCpus -- +1 since current query should be excluded
- from
- (
- select Cpu_id,
- min(convert(int, is_idle)) IsIdle
- from sys.dm_os_schedulers
- group by Cpu_id
- ) q
- ;
- SELECT s.session_id, r.command, r.status,
- r.wait_type, r.scheduler_id, w.worker_address,
- w.is_preemptive, w.state, t.task_state,
- t.session_id, t.exec_context_id, t.request_id
- FROM sys.dm_exec_sessions AS s
- INNER JOIN sys.dm_exec_requests AS r
- ON s.session_id = r.session_id
- INNER JOIN sys.dm_os_tasks AS t
- ON r.task_address = t.task_address
- INNER JOIN sys.dm_os_workers AS w
- ON t.worker_address = w.worker_address
- WHERE s.is_user_process = 0;
Add Comment
Please, Sign In to add comment