SELECT 

@@SERVERNAME AS ServerName,

CASE WHEN LEFT(CAST(serverproperty('productversion') as char), 1) = 9 THEN '2005'

 WHEN LEFT(CAST(serverproperty('productversion') as char), 2) = 10 THEN '2008'

 WHEN LEFT(CAST(serverproperty('productversion') as char), 2) = 11 THEN '2012'

END AS MajorVersion,

SERVERPROPERTY ('productlevel') AS ServicePack, 

SERVERPROPERTY('productversion') AS FullVersion, 

SERVERPROPERTY ('edition') AS Edition

