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, it is very helpful to know the exact version of SQL Server installed. Especially when working on security patches and upgrades, to ensure compatibility and stability.
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 SQL Server 2016, or SQL Server 2019 for example but also the numbers that goes after, for example Microsoft SQL Server 2016 – 13.0.5366.0.
How to display the SQL Server version with a query ?
The answer to this question is simple and there are different ways to display the database server version. The full list of SQL Server versions is available on the official sql server version web page. First option is to use the @@VERSION system variable.
SELECT @@VERSION;
Display MS SQL version with with a stored procedure
The second option to display the MS SQL detailed version number is to use a query with the sp_server_info system procedur.
EXEC sp_server_info 2;
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 attribute_value column and is:
attribute_id | attribute_name | attribute_value |
2 | DBMS_VER | Microsoft SQL Server 2019 – 15.0.2095.3 |
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 how to manage text larger then 8000 characters within a script.
Be the first to comment