2

I have an installation code which checks the version of the SQL Server installed by reading the version number from the registry key

SOFTWARE\Microsoft\MSSQLServer\MSSQLServer\CurrentVersion 
-> current version.

I installed SQL Server 2012 Express and this key does not exist.

SQL Server 2012 (non-express) does have this key.

Before I go and change my code to actually run a query to get the version - is there some other registry key which holds the express version number?

Thank you.

marc_s
  • 732,580
  • 175
  • 1,330
  • 1,459
yaronkl
  • 510
  • 2
  • 5
  • 18
  • 1
    Does any answer here help? https://social.msdn.microsoft.com/Forums/sqlserver/en-US/e31cddc9-b927-45d8-a848-28e1bdf3aea0/registry-keys-to-check-for-sql-server-2008-r2-express?forum=sqlgetstarted – zedfoxus Dec 24 '15 at 05:42

2 Answers2

3

You need to go check this key for the list of installed instances on your machine:

HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Microsoft SQL Server\Instance Names\SQL

This will list all available instance. Those are again names of a registry key, so if you find a key of SQLEXPRESS, it will have a string value - in my case, it's MSSQL12.SQLEXPRESS.

With that value, again look in the registry for:

HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Microsoft SQL Server\(instance-name)

This registry subtree has a lot of information about this particular instance, including (in the Setup subtree) information about the version and such

marc_s
  • 732,580
  • 175
  • 1,330
  • 1,459
1

I think you can do by simple querying (not going to registry):

select serverproperty('edition')

Result on express instance:

Express Edition

Result on non-express instance:

Enterprise Edition (64-bit)

More information can be retrieved using select @@version

Alexei - check Codidact
  • 22,016
  • 16
  • 145
  • 164