Guest User

Untitled

a guest
Dec 10th, 2018
53
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.73 KB | None | 0 0
  1. select count(*) as Cpus,
  2. sum(IsIdle) + 1 as IdleCpus -- +1 since current query should be excluded
  3. from
  4. (
  5. select Cpu_id,
  6. min(convert(int, is_idle)) IsIdle
  7. from sys.dm_os_schedulers
  8. group by Cpu_id
  9. ) q
  10. ;
  11.  
  12. SELECT s.session_id, r.command, r.status,
  13. r.wait_type, r.scheduler_id, w.worker_address,
  14. w.is_preemptive, w.state, t.task_state,
  15. t.session_id, t.exec_context_id, t.request_id
  16. FROM sys.dm_exec_sessions AS s
  17. INNER JOIN sys.dm_exec_requests AS r
  18. ON s.session_id = r.session_id
  19. INNER JOIN sys.dm_os_tasks AS t
  20. ON r.task_address = t.task_address
  21. INNER JOIN sys.dm_os_workers AS w
  22. ON t.worker_address = w.worker_address
  23. WHERE s.is_user_process = 0;
Add Comment
Please, Sign In to add comment