{"id":6457,"date":"2022-02-27T06:58:00","date_gmt":"2022-02-27T05:58:00","guid":{"rendered":"https:\/\/expert-only.com\/?p=6457"},"modified":"2022-12-12T18:29:18","modified_gmt":"2022-12-12T17:29:18","slug":"query-to-display-sql-server-version","status":"publish","type":"post","link":"https:\/\/expert-only.com\/en\/dba\/query-to-display-sql-server-version\/","title":{"rendered":"Query to display SQL Server version details"},"content":{"rendered":"\n<h4 class=\"has-text-align-center wp-block-heading\"><strong><em>Display the SQL Server version number with details using a query?<\/em><\/strong><\/h4>\n\n\n\n<p>Using SQL Server Management Studio, here is a query to display SQL Server exact version. It is possible by using simple T-SQL queries and stored procedures. For example, it is very helpful to know the exact version of SQL Server installed. Especially when working on <strong>security patches and upgrades<\/strong>, to ensure compatibility and stability. <\/p>\n\n\n\n<p>But also, when third-party software needs a specific version of SQL Server to work properly. To clarify, the SQL Server exact number is not only <em>SQL Server 2016<\/em>, or <em>SQL Server 2019<\/em> for example but also the numbers that goes after, for example Microsoft SQL Server 2016 &#8211; 13.0.5366.0.<\/p>\n\n\n\n<h2 class=\"wp-block-heading\" id=\"h-how-to-display-the-sql-server-version-with-a-query\">How to display the SQL Server version with a query ?<\/h2>\n\n\n\n<p>The answer to this question is simple and there are different ways to display the database server version.&nbsp; The full list of SQL Server versions is available on the <a href=\"https:\/\/docs.microsoft.com\/en-us\/troubleshoot\/sql\/general\/determine-version-edition-update-level\" target=\"_blank\" rel=\"noreferrer noopener nofollow\">official sql server version web page<\/a>. First option is to use the @@VERSION <a href=\"https:\/\/managingresearchlibrary.org\/glossary\/system-variables\" target=\"_blank\" rel=\"noreferrer noopener\">system variable<\/a>.<\/p>\n\n\n\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"sql\" data-enlighter-theme=\"\" data-enlighter-highlight=\"\" data-enlighter-linenumbers=\"\" data-enlighter-lineoffset=\"\" data-enlighter-title=\"\" data-enlighter-group=\"\">SELECT @@VERSION; \n<\/pre>\n\n\n\n<h2 class=\"wp-block-heading\" id=\"h-display-ms-sql-version-with-with-a-stored-procedure\">Display MS SQL version with with a stored procedure<\/h2>\n\n\n\n<p>The second option to display the MS SQL detailed version number is to use a query with the <em>sp_server_info<\/em> system procedur.<\/p>\n\n\n\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"sql\" data-enlighter-theme=\"\" data-enlighter-highlight=\"\" data-enlighter-linenumbers=\"\" data-enlighter-lineoffset=\"\" data-enlighter-title=\"\" data-enlighter-group=\"\">EXEC sp_server_info 2;\n<\/pre>\n\n\n\n<p>The result is the DBMS_VER system attribute which is the SQL Server version. In this example, the query displays the exact number in the <em>attribute_value<\/em> column and is:<\/p>\n\n\n\n<figure class=\"wp-block-table\"><table><tbody><tr><td class=\"has-text-align-center\" data-align=\"center\"><em>attribute_id<\/em><\/td><td class=\"has-text-align-center\" data-align=\"center\"><em>attribute_name<\/em><\/td><td class=\"has-text-align-center\" data-align=\"center\"><em>attribute_value<\/em><\/td><\/tr><tr><td class=\"has-text-align-center\" data-align=\"center\"><strong>2<\/strong><\/td><td class=\"has-text-align-center\" data-align=\"center\"><strong>DBMS_VER<\/strong><\/td><td class=\"has-text-align-center\" data-align=\"center\"><strong>Microsoft SQL Server 2019 &#8211; 15.0.2095.3<\/strong><\/td><\/tr><\/tbody><\/table><figcaption class=\"wp-element-caption\">Result of the query to display the SQL Server version in SSMS<\/figcaption><\/figure>\n\n\n\n<p>In conclusion, these 2 different options are very quick to execute. The queries display the SQL Server version number with 2 different level of details. This section of the blog explains some T-SQL tips like for example <a href=\"https:\/\/expert-only.com\/en\/t-sql\/sql-server-text-with-more-than-8000-characters\/\">how to manage text larger then 8000 characters within a script<\/a>.<\/p>\n\n\n\n<h2 class=\"wp-block-heading\">Tutorials on MS database administration<\/h2>\n\n\n\n<ul class=\"wp-block-list\">\n<li><a href=\"https:\/\/expert-only.com\/en\/dba\/create-sql-server-database-with-ssms\/\">Create a SQL Server database with SSMS<\/a><\/li>\n\n\n\n<li><a href=\"https:\/\/expert-only.com\/en\/dba\/clear-transaction-log\/\">Clear the MS SQL transaction log and fix 9002 error<\/a><\/li>\n<\/ul>\n","protected":false},"excerpt":{"rendered":"<div class=\"mh-excerpt\"><p>Display the SQL Server version number with details using a query? Using SQL Server Management Studio, here is a query to display SQL Server exact version. It is possible by using simple T-SQL queries and stored procedures. For example, <a class=\"mh-excerpt-more\" href=\"https:\/\/expert-only.com\/en\/dba\/query-to-display-sql-server-version\/\" title=\"Query to display SQL Server version details\">&#8230;<\/a><\/p>\n<\/div>","protected":false},"author":1,"featured_media":5961,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[488],"tags":[],"class_list":{"0":"post-6457","1":"post","2":"type-post","3":"status-publish","4":"format-standard","5":"has-post-thumbnail","7":"category-dba"},"_links":{"self":[{"href":"https:\/\/expert-only.com\/en\/wp-json\/wp\/v2\/posts\/6457","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/expert-only.com\/en\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/expert-only.com\/en\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/expert-only.com\/en\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/expert-only.com\/en\/wp-json\/wp\/v2\/comments?post=6457"}],"version-history":[{"count":0,"href":"https:\/\/expert-only.com\/en\/wp-json\/wp\/v2\/posts\/6457\/revisions"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/expert-only.com\/en\/wp-json\/wp\/v2\/media\/5961"}],"wp:attachment":[{"href":"https:\/\/expert-only.com\/en\/wp-json\/wp\/v2\/media?parent=6457"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/expert-only.com\/en\/wp-json\/wp\/v2\/categories?post=6457"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/expert-only.com\/en\/wp-json\/wp\/v2\/tags?post=6457"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}