How to clean up a SQL 2005 instance name left behind by a previous uninstall
I have heard from a few customers who have tried to uninstall and re-install SQL 2005 and have run into errors with both the uninstall and the re-install. I have already described the most common uninstall error and a suggested workaround in this previous blog post (an error reading property "Installids" from the cache and/or an error writing property "flagCommit" to the cache).
I wanted to address one of the most common SQL Express install errors I have seen - a duplicate instance name error that causes SQL setup to fail and rollback. It is pretty easy to tell if you are running into this error if you launch SQL setup directly and step through the SQL setup UI. However, if you are installing SQL Express as a part of Visual Studio 2005, setup runs in silent mode and you will only see a generic error bubbled up from Visual Studio setup indicating that SQL Express failed to install.
VS 2005 configures SQL Express with an instance name of SQLEXPRESS when it runs SQL setup in silent mode. If you previously had SQL Express installed and try to uninstall it but something goes wrong with uninstall, you may end up with an orphaned instance name on your system, and then re-installing SQL Express can fail. In this case, the verbose setup log file for SQL Express will show an error that looks like the following:
MSI (s) (AC!38) [00:01:41:056]: Product: Microsoft SQL Server 2005 Express Edition -- Error 28086. An instance with the same name is already installed on this computer. To proceed with SQL Server Setup, provide a unique instance name.
Error 28086. An instance with the same name is already installed on this computer. To proceed with SQL Server Setup, provide a unique instance name.
If you are running into an error installing SQL Express as a part of Visual Studio 2005 setup, you can check in the SQL Express log files (located at %ProgramFiles%\Microsoft SQL Server\90\Setup Bootstrap\LOG). If you are receiving an error about the instance name not being unique, you can manually clean off the orphaned instance name by doing the following:
- Click on the Start menu, choose Run and type regedit
- Go to HKEY_LOCAL_MACHINE\Software\Microsoft\Microsoft SQL Server
- Remove SQLEXPRESS from the REG_MULTI_SZ value named InstalledInstances
- Delete the subhive named MSSQL.1
- Delete the subhive named SQLEXPRESS
- Go to HKEY_LOCAL_MACHINE\Software\Microsoft\Microsoft SQL Server\Instance Names\SQL
- Delete the value named SQLEXPRESS
- Delete the folder %ProgramFiles%\Microsoft SQL Server\MSSQL.1
Note - the above steps apply to the instance name that is created when SQL Express is installed as a part of Visual Studio 2005. The actual instance name on your system may vary if you have had any other beta version of SQL 2005 (such as the developer edition). Please make sure to adjust the steps accordingly based on what instance name information is in your registry and file system.
<update date="7/24/2009"> Updated this post to not be beta-specific. The same type of error can occur if you uninstall and re-install the final release of SQL Express or SQL Express service packs. </update>