info@techdevops.com
TechDevOps.com
Explore Tools
Experts in Microsoft SQL Server Operations, Performance, Replication, Cloud & Migrations



How to check if SQL Server is running on a Physical or Virtual Machine
by BF (Senior MSSQL Operations - Enterprise, Cloud, Strategy)
2015-08-02






Solution:


TSQL #1:

SELECT
SERVERPROPERTY('computernamephysicalnetbios') AS ServerName
,t1.virtual_machine_type_desc
,Server_type = CASE WHEN t1.virtual_machine_type = 1 THEN 'Virtual' ELSE 'Physical' END
FROM sys.dm_os_sys_info t1

Results Set:
[ServerName] [virtual_machine_type_desc] [Server_type]
NYC-DB-01 HYPERVISOR Virtual

Results Set:
[ServerName] [virtual_machine_type_desc] [Server_type]
PRD-SRV-01 NONE Physical


TSQL #2:

DECLARE @result int
EXEC @result = xp_cmdshell 'SYSTEMINFO'

Results Set:
System Manufacturer: VMware, Inc.
System Model: VMware Virtual Platform

Results Set:
System Manufacturer: HP
System Model: ProLiant DL580 G5


TSQL #3:

select @@version

Results Set: (see end of string - Hypervisor)
Microsoft Corporation Standard Edition (64-bit) on Windows NT 6.1 <X64> (Build 7601: Service Pack 1) (Hypervisor)


CMD Prompt: MSINFO32

System Manufacturer: VMware, Inc.
System Model: VMware Virtual Platform


Powershell:

get-wmiobject win32_computersystem | fl model

Output:

model : VMware Virtual Platform

(fl = format list)