How Old Version of SQL Server Running on Server? – Interview Question of the Week #183

Question: How do I find out which SQL Server version is running, and how old its build is?

Answer: Run SELECT @@VERSION. It returns the Database Engine version, build number, build date and edition in one string.

Growth rings in an established oak log beside a young sapling

This came up during a Comprehensive Database Performance Health Check. I assumed everyone knew the command, but it was a useful reminder that the small checks matter. I run it early in a consulting engagement so I know which engine and patch level I am investigating.

SELECT @@VERSION;
Historical SELECT @@VERSION output for SQL Server 2017 CU8, build 14.0.3029.16
The original SQL Server 2017 CU8 example. The build date shown is June 13, 2018.

That date is the engine build date. It is not the date the customer installed SQL Server, the last time the service started, or the date the patch was applied. The build number and CU or servicing branch tell you more about what is installed than the major release name alone.

If you need separate columns for an inventory, use SERVERPROPERTY instead of parsing the long string:

SELECT SERVERPROPERTY('ProductVersion') AS ProductVersion,
       SERVERPROPERTY('ProductLevel') AS ProductLevel,
       SERVERPROPERTY('ProductUpdateLevel') AS ProductUpdateLevel,
       SERVERPROPERTY('Edition') AS Edition;

A property can return NULL when it is not applicable or is unsupported on that engine. Compare the resulting build with Microsoft’s version history for the relevant release. Keep the Database Engine version separate from the SSMS version and a database’s compatibility level.

Related reading:

Published by Pinal Dave on SQLAuthority. More of my work at pinaldave.com.


Discover more from SQL Authority with Pinal Dave

Subscribe to get the latest posts sent to your email.

SQL Patch, SQL Scripts, SQL Server
Previous Post
How to Convert Hex Windows Error Codes to the Meaningful Error Message – 0x80040002 and 0x80040005 and others? – Interview Question of the Week #182
Next Post
How to Check Status of Instant File Initialization? – Interview Question of the Week #184

Related Posts

Leave a Reply

Your email address will not be published. Required fields are marked *

Fill out this field
Fill out this field
Please enter a valid email address.