SQL Server, or more specifically, Transact-SQL, includes a number of built in functions, including the @@version
scalar function. The @@version
function is a configuration function, which returns system and build information for the current installation of SQL Server. You can run this function at any time to find out which version of SQL Server you’re using.
Here’s how:
SELECT @@version;
When running that in a command line interface, you might see results that look like this:
Microsoft SQL Server 2017 (RTM-CU6) (KB4101464) - 14.0.3025.34 (X64) Apr 9 2018 18:00:41 Copyright (C) 2017 Microsoft Corporation Developer Edition (64-bit) on Linux (Ubuntu 16.04.4 LTS) 1 row(s) returned Executed in 1 ms
If you run it in a GUI interface, it will probably be one long unformatted string, like this:
Microsoft SQL Server 2017 (RTM-CU6) (KB4101464) - 14.0.3025.34 (X64) Apr 9 2018 18:00:41 Copyright (C) 2017 Microsoft Corporation Developer Edition (64-bit) on Linux (Ubuntu 16.04.4 LTS)
Obviously, your results will depend on the version of SQL Server that you use, its edition, as well as the operating system you’re running on.
The SERVERPROPERTY() Function
You can also use the SERVERPROPERTY()
function, which returns property information about the server instance:
SELECT SERVERPROPERTY('Edition') AS Edition, SERVERPROPERTY('ProductVersion') AS Version; GO
Running that in a GUI like SSMS or Azure Data Studio returns the results like this:
Edition | Version |
---|---|
Developer Edition (64-bit) | 14.0.3025.34 |