Created
January 5, 2020 15:16
-
-
Save LiCongMingDeShujuku/118a3f324b39fc3ba306ff77a9b0e16a to your computer and use it in GitHub Desktop.
Get Number Of Cores With SQL
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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