Search code examples
sql-server-2012sql-server-2012-express

SQL Server 2012 Express version in registry


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.


Solution

  • 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