There was a time when SQL Server used to run on only Microsoft Windows. However, the time has changed, and SQL Server now runs on Linux as well. This is indeed a great move as I believe database such as SQL Server should be running on multiple platforms. This is indeed a very interesting but it ads one more additional check before I jump into Comprehensive Database Performance Health Check. In this blog post, we will learn about how to get host information from OS.
Earlier during consultancy, I always assumed that SQL Server is running on Windows, but now I also have to check if it is running on Linux or not. In earlier times I was able to do this with DMV which was related to Windows Only (sys.dm_os_windows_info). However, this DMV will not work on Linux machine. If you use earlier DMV, it will return empty results on Linux.
I quickly looked around and figured out that in SQL Server 2017, Microsoft has introduced new DMV which works on both the platform – Windows and Linux. Now onwards you can use this new DMV to get necessary information related to the host.
Let us see a simple example:
SELECT *
FROM sys.dm_os_host_infoWhen you run above script it will bring us following results:

Well, as my most of the scripts check the details about the OS, I will have to change them to depend on new DMV as that is more robust and works with any operating system platform.
Published by Pinal Dave on SQLAuthority. More of my work at pinaldave.com.




