Finding the SQL Server version with query We can use the @@VERSION function to find out all version details of the SQL Server instance. The @@VERSION function returns a one-line string output and this output also provides all the necessary information about the SQL Server.
Likewise, this same information can be found directly in the SQL Server Configuration Manager tool. Once you open it up, right-click on your SQL Server service and go into Properties. Then click on the Advanced tab and look at the Stock Keeping Unit Name key. There will you find what edition you are using.
Try
SELECT @@VERSION
or for SQL Server 2000 and above the following is easier to parse :)
SELECT SERVERPROPERTY('productversion')
, SERVERPROPERTY('productlevel')
, SERVERPROPERTY('edition')
From: http://support.microsoft.com/kb/321185
SELECT @@VERSION
I know this is an older post but I updated the code found in the link (which is dead as of 2013-12-03) mentioned in the answer posted by Matt Rogish:
DECLARE @ver nvarchar(128)
SET @ver = CAST(serverproperty('ProductVersion') AS nvarchar)
SET @ver = SUBSTRING(@ver, 1, CHARINDEX('.', @ver) - 1)
IF ( @ver = '7' )
SELECT 'SQL Server 7'
ELSE IF ( @ver = '8' )
SELECT 'SQL Server 2000'
ELSE IF ( @ver = '9' )
SELECT 'SQL Server 2005'
ELSE IF ( @ver = '10' )
SELECT 'SQL Server 2008/2008 R2'
ELSE IF ( @ver = '11' )
SELECT 'SQL Server 2012'
ELSE IF ( @ver = '12' )
SELECT 'SQL Server 2014'
ELSE IF ( @ver = '13' )
SELECT 'SQL Server 2016'
ELSE IF ( @ver = '14' )
SELECT 'SQL Server 2017'
ELSE
SELECT 'Unsupported SQL Server Version'
For SQL Server 2000 and above, I prefer the following parsing of Joe's answer:
declare @sqlVers numeric(4,2)
select @sqlVers = left(cast(serverproperty('productversion') as varchar), 4)
Gives results as follows:
Result Server Version 8.00 SQL 2000 9.00 SQL 2005 10.00 SQL 2008 10.50 SQL 2008R2 11.00 SQL 2012 12.00 SQL 2014
Basic list of version numbers here, or exhaustive list from Microsoft here.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With