#SQLHacker: Determine if You’re SQL Instance is on a VM Using T/SQL

#SQLHacker: Determine if You’re SQL Instance is on a VM Using T/SQL

 

@@:  It’s Not Just a Method of Imperial Troop Transport

SELECT @@VERSION;  It’s been a valid statement in Microsoft SQL Sever since at least SQL Server 2000.  (One could assume further back then 2000 even, but if you’re lucky you don’t have any SQL B.2K. instances to test against.)

Every version of SQL Server since 2008 has allowed you to use the SELECT @@VERSION; command to return not only information on both the version and patch level of SQL Server and the Windows operating system it’s running on, but also on whether the instance is virtualized.  The terminology may differ, but the information is there.  Each of the instances below are running on a guest OS on the same VMware Host:

SQL 2005 Results Sample

Microsoft SQL Server 2005 - 9.00.5000.00 (X64) 	Dec 10 2010 10:38:40 	Copyright (c) 1988-2005 Microsoft Corporation	Enterprise Edition (64-bit) on Windows NT 6.1 (Build 7601: Service Pack 1)

SQL 2008 Results Sample

Microsoft SQL Server 2008 (SP3) - 10.0.5500.0 (X64) 	Sep 21 2011 22:45:45 	Copyright (c) 1988-2008 Microsoft Corporation	Enterprise Edition (64-bit) on Windows NT 6.1  (Build 7601: Service Pack 1) (VM)

SQL 2008R2 Results Sample

Microsoft SQL Server 2008 R2 (SP1) - 10.50.2500.0 (X64) 	Jun 17 2011 00:54:03 	Copyright (c) Microsoft Corporation	Enterprise Edition (64-bit) on Windows NT 6.1  (Build 7601: Service Pack 1) (Hypervisor)

SQL 2012 Results Sample

Microsoft SQL Server 2012 - 11.0.2100.60 (X64) 	Feb 10 2012 19:39:15 	Copyright (c) Microsoft Corporation	Standard Edition (64-bit) on Windows NT 6.1  (Build 7601: Service Pack 1) (Hypervisor)