SQL Clone
SQLServerCentral is supported by Redgate
 
Log in  ::  Register  ::  Not logged in
 
 
 


Number of Processors(SQL Query)


Number of Processors(SQL Query)

Author
Message
Waseem Jaleel
Waseem Jaleel
Old Hand
Old Hand (399 reputation)Old Hand (399 reputation)Old Hand (399 reputation)Old Hand (399 reputation)Old Hand (399 reputation)Old Hand (399 reputation)Old Hand (399 reputation)Old Hand (399 reputation)

Group: General Forum Members
Points: 399 Visits: 606
Please help me if there is any method to retreive using query, the number of processors in a server on which sql server is installled
GilaMonster
GilaMonster
SSC Guru
SSC Guru (219K reputation)SSC Guru (219K reputation)SSC Guru (219K reputation)SSC Guru (219K reputation)SSC Guru (219K reputation)SSC Guru (219K reputation)SSC Guru (219K reputation)SSC Guru (219K reputation)

Group: General Forum Members
Points: 219281 Visits: 46279
Yes, there is. You can use the xp_msver extended procedure. I'm not sure of the security requirements

exec xp_msver 'ProcessorCount'



Gail Shaw
Microsoft Certified Master: SQL Server, MVP, M.Sc (Comp Sci)
SQL In The Wild: Discussions on DB performance with occasional diversions into recoverability

We walk in the dark places no others will enter
We stand on the bridge and no one may pass


Zksod
Zksod
SSC-Enthusiastic
SSC-Enthusiastic (177 reputation)SSC-Enthusiastic (177 reputation)SSC-Enthusiastic (177 reputation)SSC-Enthusiastic (177 reputation)SSC-Enthusiastic (177 reputation)SSC-Enthusiastic (177 reputation)SSC-Enthusiastic (177 reputation)SSC-Enthusiastic (177 reputation)

Group: General Forum Members
Points: 177 Visits: 377
/* well, this will work, though it is a little elaborate. it does however provide some other cool info about the processer(s)*/
DECLARE
@nProcessorCount INT
,@vcProcessorModel VARCHAR(5)
,@vcProcessorType VARCHAR(30)
,@vcProcessorNameString VARCHAR(60)

CREATE TABLE #tblStats
(
[Index] INT,
[Name] VARCHAR(200),
Internal_Value VARCHAR(50),
Character_Value VARCHAR(200)
)

INSERT INTO #tblStats
EXEC master.dbo.xp_msver 'ProcessorCount'
INSERT INTO #tblStats
EXEC master.dbo.xp_msver 'ProcessorType'
INSERT INTO #tblStats
EXEC master.dbo.xp_msver 'ProcessorType'


SELECT @nProcessorCount = Internal_Value FROM #tblStats WHERE [Index] = 16
SELECT @vcProcessorModel = Internal_Value FROM #tblStats WHERE [Index] = 18
SELECT @vcProcessorType = Character_Value FROM #tblStats WHERE [Index] = 18

EXEC master.dbo.xp_instance_regread N'HKEY_LOCAL_MACHINE',
N'HARDWARE\DESCRIPTION\System\CentralProcessor\0',
N'ProcessorNameString',
@vcProcessorNameString OUTPUT,
N'no_output'

SELECT
@nProcessorCount
,@vcProcessorModel
,@vcProcessorType
,@vcProcessorNameString


DROP TABLE #tblStats

-- let me know if you have any issues
2 Tim 3:16
2 Tim 3:16
SSCommitted
SSCommitted (1.8K reputation)SSCommitted (1.8K reputation)SSCommitted (1.8K reputation)SSCommitted (1.8K reputation)SSCommitted (1.8K reputation)SSCommitted (1.8K reputation)SSCommitted (1.8K reputation)SSCommitted (1.8K reputation)

Group: General Forum Members
Points: 1825 Visits: 1547
Since MS licenses on actual CPU (and not cores) I needed to find out the actual cpu for our servers. Our sysadmin provided me an executable (attached) that is exactly what I needed. Change the .txt to .exe and you're good-to-go.

Tim White
Attachments
Intel-CPU-Count.txt (555 views, 48.00 KB)
2 Tim 3:16
2 Tim 3:16
SSCommitted
SSCommitted (1.8K reputation)SSCommitted (1.8K reputation)SSCommitted (1.8K reputation)SSCommitted (1.8K reputation)SSCommitted (1.8K reputation)SSCommitted (1.8K reputation)SSCommitted (1.8K reputation)SSCommitted (1.8K reputation)

Group: General Forum Members
Points: 1825 Visits: 1547
You can also download this code at http://softwarecommunity.intel.com/articles/eng/2728.htm

Tim White
Waseem Jaleel
Waseem Jaleel
Old Hand
Old Hand (399 reputation)Old Hand (399 reputation)Old Hand (399 reputation)Old Hand (399 reputation)Old Hand (399 reputation)Old Hand (399 reputation)Old Hand (399 reputation)Old Hand (399 reputation)

Group: General Forum Members
Points: 399 Visits: 606
I thank all of you for all the responses, this has been very useful to me, I have finally decided to use the xp_msver, by Gail Shaw. Thank you very much once again.
2 Tim 3:16
2 Tim 3:16
SSCommitted
SSCommitted (1.8K reputation)SSCommitted (1.8K reputation)SSCommitted (1.8K reputation)SSCommitted (1.8K reputation)SSCommitted (1.8K reputation)SSCommitted (1.8K reputation)SSCommitted (1.8K reputation)SSCommitted (1.8K reputation)

Group: General Forum Members
Points: 1825 Visits: 1547
Just want to make sure you understand that this is a "core" count and not a true cpu count.

Tim White
Waseem Jaleel
Waseem Jaleel
Old Hand
Old Hand (399 reputation)Old Hand (399 reputation)Old Hand (399 reputation)Old Hand (399 reputation)Old Hand (399 reputation)Old Hand (399 reputation)Old Hand (399 reputation)Old Hand (399 reputation)

Group: General Forum Members
Points: 399 Visits: 606
I understand that it gives the number of cores and not the actual number of physical processors, I believe this is the only option available as I did not see any suggestion which would give the number of physical processors, other than a manual check. I required this as a sql query since i need to run this from a central server on a larger number of servers added as linked servers to the central server. Your replies are enough for me to work on this requirement. Thanks a lot all of you!!
GabyYYZ
GabyYYZ
SSCommitted
SSCommitted (1.8K reputation)SSCommitted (1.8K reputation)SSCommitted (1.8K reputation)SSCommitted (1.8K reputation)SSCommitted (1.8K reputation)SSCommitted (1.8K reputation)SSCommitted (1.8K reputation)SSCommitted (1.8K reputation)

Group: General Forum Members
Points: 1803 Visits: 2336
Try this, it's something I wrote to automate a program that could be optimized on number of processors used:


create procedure num_processors
as
set nocount on
declare @numprocs int
create table #numprocs
(
id int,
colname varchar(128),
IV int,
CV varchar(128)
)
insert #numprocs
exec master..xp_msver
select @numprocs = IV from #numprocs
where colname like '%ProcessorCount%'
drop table #numprocs
return @numprocs
go



Hope it helps. It gets the actual internal processor representation from SQL Server so hopefully it is accurate.

Gaby
________________________________________________________________
"In theory, theory and practice are the same. In practice, they are not."
- Albert Einstein

Orlando Colamatteo
Orlando Colamatteo
SSC-Dedicated
SSC-Dedicated (38K reputation)SSC-Dedicated (38K reputation)SSC-Dedicated (38K reputation)SSC-Dedicated (38K reputation)SSC-Dedicated (38K reputation)SSC-Dedicated (38K reputation)SSC-Dedicated (38K reputation)SSC-Dedicated (38K reputation)

Group: General Forum Members
Points: 38586 Visits: 14411
Waseem Jaleel (7/28/2008)
I thank all of you for all the responses, this has been very useful to me, I have finally decided to use the xp_msver, by Gail Shaw. Thank you very much once again.

I know this is a really old thread but I found it through Google looking for something else so I am confident others will too. xp_msver does not show physical CPU sockets, it shows logical processors.

This will show you the number of physical sockets on your server:

SELECT  cpu_count / hyperthread_ratio AS physical_cpu_sockets
FROM sys.dm_os_sys_info ;




Credit: http://sqlblog.com/blogs/kalen_delaney/archive/2007/12/08/hyperthreaded-or-not.aspx

__________________________________________________________________________________________________
There are no special teachers of virtue, because virtue is taught by the whole community. --Plato
Go


Permissions

You can't post new topics.
You can't post topic replies.
You can't post new polls.
You can't post replies to polls.
You can't edit your own topics.
You can't delete your own topics.
You can't edit other topics.
You can't delete other topics.
You can't edit your own posts.
You can't edit other posts.
You can't delete your own posts.
You can't delete other posts.
You can't post events.
You can't edit your own events.
You can't edit other events.
You can't delete your own events.
You can't delete other events.
You can't send private messages.
You can't send emails.
You can read topics.
You can't vote in polls.
You can't upload attachments.
You can download attachments.
You can't post HTML code.
You can't edit HTML code.
You can't post IFCode.
You can't post JavaScript.
You can post emoticons.
You can't post or upload images.

Select a forum

































































































































































SQLServerCentral


Search