Quick Answer
Just run the following:
{InstanceHome}\MSSQL\Binn\sqlservr.exe -v [-s InstanceName]
NOTE ABOUT SQL Server Express LocalDB: LocalDB can only be determined by the
existence of the following folder:
C:\Program Files\Microsoft SQL Server\{SQL Server Version: 110, 120, etc}\LocalDB\Binn
Running "sqlserver.exe -v" doesn't help as it reports as being "Developer Edition", and
searching the Registry it reports as being "Express Edition".
This method always works, unlike the other solutions which won't work when:
- you don't want to write a program (for example, PowerShell)?
- the Client Tools haven't been installed (required to use SQLCMD.EXE)?
- There is either no SQL Server log file, or there is no log file that contains any start/restart events?
- SQL Server is not running (hence
SELECT @@VERSION;
is not an option)?
Example 1
If you only have a single Instance installed, you do not need to use the -s
switch:
C:\Program Files\Microsoft SQL Server\MSSQL11.MSSQLSERVER\MSSQL\Binn>sqlservr.exe -v
Returns:
2015-08-01 11:40:11.63 Server Logging to event log is disabled. Startup option '-v' is supplied, either from the registry or the command prompt.
2015-08-01 11:40:11.63 Server Microsoft SQL Server 2012 - 11.0.5343.0 (X64)
May 4 2015 19:11:32
Copyright (c) Microsoft Corporation
Developer Edition (64-bit) on Windows NT 6.2 <X64> (Build 9200: )
2015-08-01 11:40:11.63 Server (c) Microsoft Corporation.
2015-08-01 11:40:11.63 Server All rights reserved.
2015-08-01 11:40:11.63 Server Server process ID is 3824.
2015-08-01 11:40:11.63 Server System Manufacturer: '{CompanyName}', System Model: '{ModelNumber}'.
2015-08-01 11:40:11.63 Server Authentication mode is MIXED.
2015-08-01 11:40:11.63 Server The service account is '{AccountName}'. This is an informational message; no user action is required.
2015-08-01 11:40:11.63 Server SQL Server shutdown has been initiated
Example 2
If you have multiple Instances installed on the machine, you need to also use the -s
switch to specify which Instance you are interested in, else it can intermix version info:
C:\Program Files\Microsoft SQL Server\MSSQL12.SQLEXPRESS2014\MSSQL\Binn>sqlservr.exe -v
-s SQLEXPRESS2014
Returns:
2015-08-01 12:01:13.13 Server Logging to event log is disabled. Startup option '-v' is supplied, either from the registry or the command prompt.
2015-08-01 12:01:13.13 Server Microsoft SQL Server 2014 - 12.0.4213.0 (X64)
Jun 9 2015 12:06:16
Copyright (c) Microsoft Corporation
Express Edition (64-bit) on Windows NT 6.2 <X64> (Build 9200: )
2015-08-01 12:01:13.13 Server UTC adjustment: -4:00
2015-08-01 12:01:13.13 Server (c) Microsoft Corporation.
2015-08-01 12:01:13.13 Server All rights reserved.
2015-08-01 12:01:13.13 Server Server process ID is 1712.
2015-08-01 12:01:13.13 Server System Manufacturer: '{CompanyName}', System Model: '{ModelNumber}'.
2015-08-01 12:01:13.13 Server Authentication mode is WINDOWS-ONLY.
2015-08-01 12:01:13.13 Server The service account is '{AccountName}'. This is an informational message; no user action is required.
2015-08-01 12:01:13.13 Server SQL Server shutdown has been initiated
Additional Information
The quickest, easiest, and most reliable way to determine version information of a program is simply to request that information from the program. Most programs (*.COM and *.EXE) have a command-line switch / flag / parameter / option / dealy-ma-bob that will display help and/or version information.
Depending on the program itself, the command-line switch will be prefixed with one of the following:
And, again depending on the program itself, the command-line switch will be one of the following:
- Most common:
- Sometimes included in the general help info:
{ SQL Server examples shown above }
The command-line utility SQLCMD.EXE, on the other hand, uses the -v
switch to pass variable values into the SQL script, so it only displays version info in its general info display:
C:\>sqlcmd /?
Microsoft (R) SQL Server Command Line Tool
Version 11.0.2100.60 NT x64
Copyright (c) 2012 Microsoft. All rights reserved.
usage: Sqlcmd [-U login id] [-P password]
[-S server] [-H hostname] [-E trusted connection]
...
[-v var = "value"...] ...
...
[-? show syntax summary]
NotePad, however, only has a very limited set of command-line switches, and none of them display version info.
Alternative, no-fuss methods:
Check the registry:
Key: HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Microsoft SQL Server\{VersionNumber}\Tools\Setup
Name: Edition
If you know the version number (e.g. SQL Server 2012 = 110, SQL Server 2014 = 120, etc), you can the Edition for it specifically by running the following at a command prompt:
REG QUERY "HKLM\SOFTWARE\Microsoft\Microsoft SQL Server\{VersionNumber}\Tools\Setup" /v /e /f Edition
Returns one entry similar to the following:
HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Microsoft SQL Server\110\Tools\Setup
Edition REG_SZ Developer Edition
If you what to see the Edition for whatever happens to be installed, run the following at a command prompt:
REG QUERY "HKLM\SOFTWARE\Microsoft\Microsoft SQL Server" /s /v /e /f Edition
Returns one or more entries similar to the one shown above and the following:
HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Microsoft SQL Server\MSSQL11E.LOCALDB\Setup
Edition REG_SZ Express Edition
Check the installation log:
C:\Program Files\Microsoft SQL Server\{SQL Server Version: 110, 120, etc}\Setup Bootstrap\Log\{date_time}\Detail.txt
For the string "IsExpressSku":
(03) 2014-09-05 16:53:44 SQLEngine: --EffectiveProperties: IsExpressSku = True