Gets the SQL Server version details, including Operating System version.
declare @sqlVers numeric(4, 2);
select @sqlVers = LEFT(Cast(Serverproperty('productversion') as varchar), 4);
select
case @sqlVers
when 7.00
then 'SQL Server 7'
when 8.00
then 'SQL Server 2000'
when 9.00
then 'SQL Server 2005'
when 10.00
then 'SQL Server 2008'
when 10.50
then 'SQL Server 2008 R2'
when 11.00
then 'SQL Server 2012'
when 12.00
then 'SQL Server 2014'
when 13.00
then 'SQL Server 2016'
else 'UnKnown/Unsupported SQL Server Version'
end as SqlServerType,
Serverproperty('ProductVersion') as ProductVersion,
Serverproperty('ProductLevel') as ProductLevel,
Serverproperty('Edition') as Edition,
Serverproperty('ResourceLastUpdateDateTime') as LastUpdateDateTime,
case RIGHT(Substring(@@VERSION, Charindex('Windows NT', @@VERSION), 14), 3)
when '5.0'
then 'Windows 2000'
when '5.1'
then 'Windows XP'
when '5.2'
then 'Windows Server 2003 R2'
when '6.0'
then 'Windows Server 2008'
when '6.1'
then 'Windows Server 2008 R2'
when '6.2'
then 'Windows Server 2012'
else 'UnKnown Windows OS Type'
end as OSVersion;