Background
As SQL Server now runs on Linux it is likely a good idea to be able to determine the underlying OS that a specific instance is sitting on.
Choices
Here are some choices for determining a targeted SQL Instance OS Version :-
- @@version
- sys.dm_os_host_info
- SQL Server Versions
- v2017 and above
- SQL Server Versions
System Function
@@version
Syntax
select @@version
Output
Tabulated
@@version | OS/Client | OS/Server |
---|---|---|
Microsoft SQL Server 2017 (RTM-CU3-GDR) (KB4052987) – 14.0.3015.40 (X64) Dec 22 2017 16:13:22 Copyright (C) 2017 Microsoft Corporation Developer Edition (64-bit) on Windows 10 Enterprise 2016 LTSB 10.0 <X64> (Build 14393: ) |
Windows 10 | |
Microsoft SQL Server 2014 (SP2-CU7) (KB4032541) – 12.0.5556.0 (X64) Aug 17 2017 12:07:38 Copyright (c) Microsoft Corporation Standard Edition (64-bit) on Windows NT 6.3 (Build 14393: ) (Hypervisor) |
Windows Server 2016 | |
Microsoft SQL Server 2017 (RTM) – 14.0.1000.169 (X64) Aug 22 2017 17:04:49 Copyright (C) 2017 Microsoft Corporation Express Edition (64-bit) on Windows Server 2012 R2 Standard 6.3 (Build 9600: ) (Hypervisor) |
Windows 8.1 | Windows Server 2012 R2 |
Microsoft SQL Server 2014 – 12.0.4100.1 (X64) Apr 20 2015 17:29:27 Copyright (c) Microsoft Corporation Developer Edition (64-bit) on Windows NT 6.0 <X64> (Build 6002: Service Pack 2) (Hypervisor) |
Windows Vista | Windows Server 2008 |
Dynamic Management View
sys.dm_os_host_info
Syntax
SELECT host_platform , host_distribution , host_release , host_service_pack_level , host_sku , os_language_version FROM sys.dm_os_host_info ;
Output
Summary
If you happen to be running SQL Server v2017, you will have not do to all the parsing involved with getting accurate data from @@version.
Addendum
Did a similar post here.
This was back in 2010. And, that post is titled “MS SQL Server – Read OS Version“.
Windows NT 6.3
Unfortunately “Windows NT 6.3” is returned for the following OSes:
- Windows 2016
- Windows 2012
Prove
Windows Server 2016
SQL Server
master.dbo.xp_MSver
Image
Explanation
- Name :- WindowsVersion
- Internal Value :- 364118016
- Character Value :- 6.3 (14393)
WinOS
systeminfo
Image
Blogging
Blogging is an interesting option.
How much to reveal and how much to slay.
It all depends on what the original intent is.
Arguing for the sake of arguing is pointless.