Return Operating System Version Info in SQL Server with the sys.dm_os_host_info Dynamic Management View

In SQL Server, you can use the sys.dm_os_host_info system dynamic management view to return information about the underlying operating system.

This view is similar to the sys.dm_os_windows_info view, except that sys.dm_os_host_info handles Linux systems as well as Windows, and it has more columns to differentiate between the two.

Example

Here’s a quick example of the info returned by this view.

SELECT * FROM sys.dm_os_host_info;

Result:

+-----------------+---------------------+----------------+---------------------------+------------+-----------------------+
| host_platform   | host_distribution   | host_release   | host_service_pack_level   | host_sku   | os_language_version   |
|-----------------+---------------------+----------------+---------------------------+------------+-----------------------|
| Linux           | Ubuntu              | 16.04          |                           | NULL       | 0                     |
+-----------------+---------------------+----------------+---------------------------+------------+-----------------------+

Here it is again using vertical output (so you don’t have to scroll sideways):

host_platform           | Linux
host_distribution       | Ubuntu
host_release            | 16.04
host_service_pack_level | 
host_sku                | NULL
os_language_version     | 0