SQL Stuff

Find If SQL Server Is Physical Or Virtual

Here’s a quick way to determine if the server is a physical machine, or virtual machine.

This query will also return the Server Name, Machine Type, Edition, Build Number, Version Number, and Number of CPU’s on the server. Keep in mind if the server is Virtual then the type of CPU’s will always be logical, and not physical.

Additionally I’ve included the xp_cmdshell ‘systeminfo’ to return the full set of OS information so you can double check the query, and if necessary get the ‘type’ of CPU in the machine.

use master;
set nocount on

'Server Name' = serverproperty('computernamephysicalnetbios')
,	'Machine Type' = case sdosi.virtual_machine_type when '1' then 'Virtual Machine' when '0' then 'Physical Machine' end ,	'Edition' = serverproperty('edition')
,	'Build' = serverproperty('productlevel')
,	'Version Number'	= serverproperty('productversion')
,	'CPU Count' = sdosi.cpu_count
sys.dm_os_sys_info sdosi;

exec xp_cmdshell 'systeminfo';

Hope this is useful.


Categories: SQL Stuff

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Google+ photo

You are commenting using your Google+ account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )


Connecting to %s