Search

Wednesday, May 30, 2012

Detect SQL Server Version, Edition, Product Level

SELECT  
 CAST(LEFT(CAST(SERVERPROPERTY('ProductVersion') AS VARCHAR(20)), CHARINDEX('.', CAST(SERVERPROPERTY('ProductVersion') AS VARCHAR(20)), 1) - 1) AS INTEGER) AS MajorVersion  
,SERVERPROPERTY('ProductVersion') AS ProductVersion  
,CASE LEFT(CAST(SERVERPROPERTY('ProductVersion') AS VARCHAR(20)), CHARINDEX('.', CAST(SERVERPROPERTY('ProductVersion') AS VARCHAR(20)), 1) - 1)  
 WHEN 8 THEN 'SQL 2000'  
 WHEN 9 THEN 'SQL 2005'  
 WHEN 10 THEN 'SQL 2008'  
END AS ProductVersion  
,SERVERPROPERTY('Edition') AS Edition  
,SERVERPROPERTY('ProductLevel') AS ProductLevel  

No comments:

Post a Comment