Posts Tagged ‘Find the number of CPU’s through T-SQL query’

One day I have to find how many numbers of CPU are working on my DB Server, before know below options, I always take a Remote Desktop session for server and from Task Manager let know about CPU information and many more available information provided by Task Manager.

Option :1
    Using extended stored procedures XP_MSVER , there at index 16, processor count displays

Exec
xp_msver
‘processorcount’

or we can directly use processorcount
Exec
xp_msver
‘processorcount’


Option :2
    
Using ‘Set NUMBER_OF_PROCESSORS’ which run on command prompt.
Exec
xp_cmdshell
‘Set NUMBER_OF_PROCESSORS’


Option 3:
From Registry values using extended stored procedure XP_REGREAD

Declare
@key
varchar(1000)

Declare
@value
varchar(1000)

EXEC
master..xp_regread
@rootkey=‘HKEY_LOCAL_MACHINE’,@key=‘SYSTEM\CurrentControlSet\Control\Session Manager\Environment\’,@value=NUMBER_OF_PROCESSORS