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.