Below query can be used to find SQL Server and Windows/Linux OS version. please note that this DMV sys.dm_os_host_info is introduced in SQL Server 2017 which works for Windows as well as for Linux platform, so below query will work for SQL Server 2017 and above versions.

select host_platform AS OS_Type,host_distribution as OS,
serverproperty('MachineName') AS ServerName,
serverproperty('Servername') AS ServerInstanceName,
serverproperty('instancename') AS Instance,
serverproperty('Edition') AS SQLServerEdition,
serverproperty('productversion') AS ProductVersion,
Left(@@Version,charindex('-',@@version) - -5) AS VersionName
from sys.dm_os_host_info

Sample Output(for SQL Server on Windows):

Sample Output(for SQL Server on Linux):

How useful was this post?

Click on a star to rate it!

Average rating 0 / 5. Vote count: 0

No votes so far! Be the first to rate this post.