<p>Is there a system stored procedure to get the version #?</p>

[{'answer_id': 59449, 'author': 'Brannon', 'author_id': 5745, 'author_profile': 'https://Stackoverflow.com/users/5745', 'pm_score': 5, 'selected': False, 'text': '<p>SELECT @@VERSION</p>\n'}, {'answer_id': 59457, 'author': 'Joe Kuemerle', 'author_id': 4273, 'author_profile': 'https://Stackoverflow.com/users/4273', 'pm_score': 9, 'selected': True, 'text': '<p>Try </p>\n\n<pre><code>SELECT @@VERSION \n</code></pre>\n\n<p>or for SQL Server 2000 and above the following is easier to parse :) </p>\n\n<pre><code>SELECT SERVERPROPERTY(\'productversion\')\n     , SERVERPROPERTY(\'productlevel\')\n     , SERVERPROPERTY(\'edition\')\n</code></pre>\n\n<p>From: <a href="http://support.microsoft.com/kb/321185" rel="noreferrer">http://support.microsoft.com/kb/321185</a></p>\n'}, {'answer_id': 60399, 'author': 'Matt', 'author_id': 4154, 'author_profile': 'https://Stackoverflow.com/users/4154', 'pm_score': 2, 'selected': False, 'text': '<p>The KB article linked in <a href="https://stackoverflow.com/questions/59444/how-do-you-check-what-version-of-sql-server-for-a-database-using-tsql#59457">Joe\'s post</a> is great for determining which service packs have been installed for any version.  Along those same lines, <a href="http://support.microsoft.com/kb/937137" rel="nofollow noreferrer">this KB article</a> maps version numbers to specific hotfixes and cumulative updates, but it only applies to SQL05 SP2 and up.</p>\n'}, {'answer_id': 510741, 'author': 'Bruce Chapman', 'author_id': 174730, 'author_profile': 'https://Stackoverflow.com/users/174730', 'pm_score': 2, 'selected': False, 'text': "<p>Here's a bit of script I use for testing if a server is 2005 or later</p>\n\n<pre><code>declare @isSqlServer2005 bit\nselect @isSqlServer2005 = case when CONVERT(int, SUBSTRING(CONVERT(varchar(15), SERVERPROPERTY('productversion')), 0, CHARINDEX('.', CONVERT(varchar(15), SERVERPROPERTY('productversion'))))) &lt; 9 then 0 else 1 end\nselect @isSqlServer2005\n</code></pre>\n\n<p>Note : updated from original answer (see comment)</p>\n"}, {'answer_id': 3178966, 'author': 'freak', 'author_id': 383595, 'author_profile': 'https://Stackoverflow.com/users/383595', 'pm_score': 1, 'selected': False, 'text': "<p>Try this:</p>\n\n<pre><code>if (SELECT LEFT(CAST(SERVERPROPERTY('productversion') as varchar), 2)) = '10'\nBEGIN\n</code></pre>\n"}, {'answer_id': 6454881, 'author': 'Geoff', 'author_id': 55487, 'author_profile': 'https://Stackoverflow.com/users/55487', 'pm_score': 4, 'selected': False, 'text': '<p>For SQL Server 2000 and above, I prefer the following parsing of Joe\'s answer:</p>\n\n<pre><code>declare @sqlVers numeric(4,2)\nselect @sqlVers = left(cast(serverproperty(\'productversion\') as varchar), 4)\n</code></pre>\n\n<p>Gives results as follows:</p>\n\n<pre>\n<b>Result   Server Version</b>\n8.00     SQL 2000\n9.00     SQL 2005\n10.00    SQL 2008\n10.50    SQL 2008R2\n11.00    SQL 2012\n12.00    SQL 2014\n</pre>\n\n<p>Basic list of version numbers <a href="http://sqlserverbuilds.blogspot.com/" rel="noreferrer">here</a>, or exhaustive list from Microsoft <a href="https://support.microsoft.com/en-us/kb/321185?wa=wsignin1.0" rel="noreferrer">here</a>.</p>\n'}, {'answer_id': 14390702, 'author': 'Mark Kram', 'author_id': 100283, 'author_profile': 'https://Stackoverflow.com/users/100283', 'pm_score': 5, 'selected': False, 'text': '<p>I know this is an older post but I updated the code found in the <a href="http://blog.devstone.com/aaron/default,date,2006-12-15.aspx" rel="nofollow noreferrer">link</a> (which is dead as of 2013-12-03) mentioned in the <a href="https://stackoverflow.com/a/59450/15168">answer</a> posted by <a href="https://stackoverflow.com/users/2590/matt-rogish">Matt Rogish</a>:</p>\n\n<pre><code>DECLARE @ver nvarchar(128)\nSET @ver = CAST(serverproperty(\'ProductVersion\') AS nvarchar)\nSET @ver = SUBSTRING(@ver, 1, CHARINDEX(\'.\', @ver) - 1)\n\nIF ( @ver = \'7\' )\n   SELECT \'SQL Server 7\'\nELSE IF ( @ver = \'8\' )\n   SELECT \'SQL Server 2000\'\nELSE IF ( @ver = \'9\' )\n   SELECT \'SQL Server 2005\'\nELSE IF ( @ver = \'10\' )\n   SELECT \'SQL Server 2008/2008 R2\'\nELSE IF ( @ver = \'11\' )\n   SELECT \'SQL Server 2012\'\nELSE IF ( @ver = \'12\' )\n   SELECT \'SQL Server 2014\'\nELSE IF ( @ver = \'13\' )\n   SELECT \'SQL Server 2016\'\nELSE IF ( @ver = \'14\' )\n   SELECT \'SQL Server 2017\'\nELSE\n   SELECT \'Unsupported SQL Server Version\'\n</code></pre>\n'}, {'answer_id': 16571275, 'author': 'crosswalk', 'author_id': 236423, 'author_profile': 'https://Stackoverflow.com/users/236423', 'pm_score': 1, 'selected': False, 'text': "<pre><code>SELECT \n@@SERVERNAME AS ServerName,\nCASE WHEN LEFT(CAST(serverproperty('productversion') as char), 1) = 9 THEN '2005'\n WHEN LEFT(CAST(serverproperty('productversion') as char), 2) = 10 THEN '2008'\n WHEN LEFT(CAST(serverproperty('productversion') as char), 2) = 11 THEN '2012'\nEND AS MajorVersion,\nSERVERPROPERTY ('productlevel') AS MinorVersion, \nSERVERPROPERTY('productversion') AS FullVersion, \nSERVERPROPERTY ('edition') AS Edition\n</code></pre>\n"}, {'answer_id': 23385767, 'author': 'Nux', 'author_id': 333296, 'author_profile': 'https://Stackoverflow.com/users/333296', 'pm_score': 1, 'selected': False, 'text': "<p>Getting only the major SQL Server version in a single select:</p>\n\n<pre><code>SELECT  SUBSTRING(ver, 1, CHARINDEX('.', ver) - 1)\nFROM (SELECT CAST(serverproperty('ProductVersion') AS nvarchar) ver) as t\n</code></pre>\n\n<p>Returns <code>8</code> for SQL 2000, <code>9</code> for SQL 2005 and so on (tested up to 2012).</p>\n"}, {'answer_id': 25188612, 'author': 'Zia', 'author_id': 3919450, 'author_profile': 'https://Stackoverflow.com/users/3919450', 'pm_score': 2, 'selected': False, 'text': '<p>There is another extended Stored Procedure which can be used to see the Version info:</p>\n\n<pre><code>exec [master].sys.[xp_msver]\n</code></pre>\n'}, {'answer_id': 26818437, 'author': 'Alex', 'author_id': 2397221, 'author_profile': 'https://Stackoverflow.com/users/2397221', 'pm_score': 2, 'selected': False, 'text': "<pre><code>CREATE FUNCTION dbo.UFN_GET_SQL_SEVER_VERSION \n(\n)\nRETURNS sysname\nAS\nBEGIN\n    DECLARE @ServerVersion sysname, @ProductVersion sysname, @ProductLevel sysname, @Edition sysname;\n\n    SELECT @ProductVersion = CONVERT(sysname, SERVERPROPERTY('ProductVersion')), \n           @ProductLevel = CONVERT(sysname, SERVERPROPERTY('ProductLevel')),\n           @Edition = CONVERT(sysname, SERVERPROPERTY ('Edition'));\n    --see: http://support2.microsoft.com/kb/321185\n    SELECT @ServerVersion = \n        CASE \n            WHEN @ProductVersion LIKE '8.00.%' THEN 'Microsoft SQL Server 2000'\n            WHEN @ProductVersion LIKE '9.00.%' THEN 'Microsoft SQL Server 2005'\n            WHEN @ProductVersion LIKE '10.00.%' THEN 'Microsoft SQL Server 2008'\n            WHEN @ProductVersion LIKE '10.50.%' THEN 'Microsoft SQL Server 2008 R2'\n            WHEN @ProductVersion LIKE '11.0%' THEN 'Microsoft SQL Server 2012'\n            WHEN @ProductVersion LIKE '12.0%' THEN 'Microsoft SQL Server 2014'\n        END\n\n    RETURN @ServerVersion + N' ('+@ProductLevel + N'), ' + @Edition + ' - ' + @ProductVersion;\n\nEND\nGO\n</code></pre>\n"}, {'answer_id': 35787064, 'author': 'pruthvi', 'author_id': 6016258, 'author_profile': 'https://Stackoverflow.com/users/6016258', 'pm_score': -1, 'selected': False, 'text': "<p>Try this:</p>\n\n<pre><code>SELECT\n    'the sqlserver is ' + substring(@@VERSION, 21, 5) AS [sql version]\n</code></pre>\n"}, {'answer_id': 40177596, 'author': 'Allen Ackerman', 'author_id': 7053303, 'author_profile': 'https://Stackoverflow.com/users/7053303', 'pm_score': 1, 'selected': False, 'text': "<p>If all you want is the major version for T-SQL reasons, the following gives you the year of the SQL Server version for 2000 or later.</p>\n\n<p><code>SELECT left(ltrim(replace(@@Version,'Microsoft SQL Server','')),4)</code></p>\n\n<p>This code gracefully handles the extra spaces and tabs for various versions of SQL Server.</p>\n"}, {'answer_id': 42291858, 'author': 'Arif', 'author_id': 7579331, 'author_profile': 'https://Stackoverflow.com/users/7579331', 'pm_score': 0, 'selected': False, 'text': "<p>Try this:</p>\n\n<pre><code>SELECT @@VERSION[server], SERVERPROPERTY('productversion'), SERVERPROPERTY ('productlevel'), SERVERPROPERTY ('edition')\n</code></pre>\n"}, {'answer_id': 43767263, 'author': 'VAV', 'author_id': 1921460, 'author_profile': 'https://Stackoverflow.com/users/1921460', 'pm_score': 1, 'selected': False, 'text': '<p>Try</p>\n\n<pre><code>SELECT @@MICROSOFTVERSION / 0x01000000 AS MajorVersionNumber\n</code></pre>\n\n<p>For more information see: <a href="https://social.technet.microsoft.com/wiki/contents/articles/783.sql-server-versions.aspx" rel="nofollow noreferrer">Querying for version/edition info</a></p>\n'}, {'answer_id': 49512753, 'author': 'Vikrant Bagal', 'author_id': 5426308, 'author_profile': 'https://Stackoverflow.com/users/5426308', 'pm_score': 1, 'selected': False, 'text': "<pre><code>select substring(@@version,0,charindex(convert(varchar,SERVERPROPERTY('productversion')) ,@@version)+len(convert(varchar,SERVERPROPERTY('productversion')))) \n</code></pre>\n"}]
['https://Stackoverflow.com/questions/59444', 'https://Stackoverflow.com', 'https://Stackoverflow.com/users/4872/']