Reputation: 1995
SQL Server 2008 R2 is one of my installer prerequisites. I know we need to check the registry entry using RegistrySearch to detect the SQL Server. I have searched through web, but I am totally confused about lot of registry entries. I have checked on my own in SQL Server 2008 R2 installed machine and found below registry entries. Could anyone please let me know which one is correct entry to check? Is there any other standard registry entry to detect SQL servers?
CurrentVersion value is 10.5
HKEY_LOCAL_MACHINE\SOFTWARE\Wow6432Node\Microsoft\Microsoft SQL Server Redist\SQLBrowser\1033\CurrentVersion
HKEY_LOCAL_MACHINE\SOFTWARE\Wow6432Node\Microsoft\Microsoft SQL Server Redist\SQLBrowser\CurrentVersion
HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Microsoft SQL Server 2008 Redist\SQLNCLI10\1033\CurrentVersion
HKEY_LOCAL_MACHINE\SOFTWARE\Wow6432Node\Microsoft\Microsoft SQL Server\100\Tools\ClientSetup\CurrentVersion
Upvotes: 2
Views: 1481
Reputation: 6637
Currently I do the following searches to check what is installed. The first two tell me that SqlServer is installed at any version. The second two tell me whether it is Sql 2008R2. I can then use these to make a decision whether to do a fresh install or upgrade an existing instance (I haven't tested whether this works with Sql2012 installed, I doubt that it will work as I don't expect you can "upgrade" Sql2012 to Sql2008R2):
<util:RegistrySearch Root="HKLM"
Key="SYSTEM\CurrentControlSet\services\MSSQL$[SqlInstance]"
Result="exists"
Variable="SQLServerInstalled" />
<util:RegistrySearch Root="HKLM"
Key="SYSTEM\CurrentControlSet\services\MSSQLSERVER"
Result="exists"
Variable="DefaultSQLServerInstalled" />
<util:RegistrySearch Root="HKLM"
Key="SOFTWARE\Microsoft\Microsoft SQL Server\MSSQL10_50.[SqlInstance]"
Result="exists"
Variable="SQLServer2008R2Installed" />
<util:RegistrySearch Root="HKLM"
Key="SOFTWARE\Microsoft\Microsoft SQL Server\MSSQL10_50.MSSQLSERVER"
Result="exists"
Variable="DefaultSQLServer2008R2Installed" />
Upvotes: 2