Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Save LiCongMingDeShujuku/118a3f324b39fc3ba306ff77a9b0e16a to your computer and use it in GitHub Desktop.
Save LiCongMingDeShujuku/118a3f324b39fc3ba306ff77a9b0e16a to your computer and use it in GitHub Desktop.
Get Number Of Cores With SQL
use master;
set nocount on
select
'physical_cpu' = cpu_count / hyperthread_ratio
, 'cores' =
case
when hyperthread_ratio = cpu_count then cpu_count
else (cpu_count / hyperthread_ratio) * ((cpu_count - hyperthread_ratio) / (cpu_count / hyperthread_ratio))
end
, 'logical_cpu' =
case
when hyperthread_ratio = cpu_count then cpu_count
else ((cpu_count - hyperthread_ratio) / (cpu_count / hyperthread_ratio))
end
from
master.sys.dm_os_sys_info
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment