Can't Remove SQL Server Instance

Leonardo Luchetti 96 Reputation points
2021-10-04T17:50:47.337+00:00

I am encountering a problem setting up SQL Express 2012 where I need to install an instance with a specific name, "ATISQLINSTANCE" but I cannot because the "Instance name is already in use". I would like to remove the previously installed instance with this name so that I can create a new one with the same name. The existing instance does not appear in SQL Server Configuration Manager (error: MMC could not create the snap-in), and it does not appear in services. I deleted the registry folder HKEY_LOCAL_MACHINE\Software\Microsoft\Microsoft SQL Server -- thinking that this would remove the installed instance, but it still appears when I run SQL Server 2012 setup to install the new instance with the same name.

I followed the steps here https://social.msdn.microsoft.com/Forums/sqlserver/en-US/b38a8bdc-a2da-4371-a8c9-487e15e9f12a/sql-server-reinstallation-error-an-instance-with-the-same-name-is-already-installed-on-this?forum=sqlsetupandupgrade which illustrate removing an SQL Instance, removing SQL from program files, removing SQL from programs, and then removing files from the registry to delete all traces of the instance, and finally restarting the PC but the old instance still appears after these steps.

It seems that the SQL 2012 Express Setup has a step called "install setup files" and I believe there may be a reference to the old ATISQLINSTANCE in the setup files that is causing the old instance to reappear on setup despite being deleted from the registry and not appearing in services. I am not sure where these setup files are located to try to remove the lines that cause the instance to reappear on setup. The attached image shows the Instance Configuration pag137495-instance-problem.pnge of the SQL Server 2012 Setup, where the problem instance can be seen under "Installed instances:".

I am at a loss for how to get rid of this instance. I need to find a way to completely remove the instance named "ATISQLINSTANCE" so that I can create a new one that is uncorrupted. I believe that SQL Express 2008 was previously installed on this machine, so this may be relevant information for someone who knows about SQL and the ways an instance can become corrupted. My company has left me on my own to fix this issue as the IT department told me they did not know how to fix this problem and chalked it up to "my machine doesn't work with SQL" I am not satisfied with this solution and I know that I can get the proper SQL instance on this machine I just need some help.

SQL Server
SQL Server
A family of Microsoft relational database management and analysis systems for e-commerce, line-of-business, and data warehousing solutions.
12,759 questions
0 comments No comments
{count} votes

Accepted answer
  1. Leonardo Luchetti 96 Reputation points
    2021-10-04T20:20:38.22+00:00

    I was able to remove the Instance - it no longer appears as an installed instance in Setup - by manually removing all references to the specific name, "ATISQLINSTANCE" in the registry. I painstakingly went through the registry and deleted every file with the word "ATISQLINSTANCE" included in the value. Using the Find and Find+next command in the registry I was able to find any reference to "ATISQLINSTANCE" and delete them. The only files I was unable to edit which had reference to "ATISQLINSTANCE" were two 'Counter' files. Then I removed the SQL program via control panel, removed the SQL folders from program files, restarted the machine, ran the setup again and the installed instance which troubled me so was no longer there. I understand that people are extremely cautious about deleting files from the registry, but SQL Setup seems to add files to the registry willy-nilly without much concern for the user. There seemed to be a registry entry for every faulty setup attempted I had tried to execute. Once I removed all these references to the old instance that were clogging up the system, immune to deletion except by manual removal, the SQL setup no longer had any reference to the old instance to point at and bother me with. There are extremely important files in the registry, but there is also a lot of useless text that can be deleted without a problem, and users should not be too afraid to solve their own problems by doing this even if it is a tedious process.


1 additional answer

Sort by: Most helpful
  1. Michael Taylor 48,581 Reputation points
    2021-10-04T18:03:23.053+00:00

    In general to remove an installed instance of SQL you run the setup again (or SQL Express setup as the case may be) and select the option to Remove as discussed here. Then you select an instanced component (such as the Database Engine) and then it asks you which instance to remove. If you manually deleted registry entries then you have messed up your installation and the setup program is going to probably not work anymore. You should never delete registry entries (or remove file system folders) until after you have successfully uninstalled the program.

    At this point there is probably no good way to know what is and isn't corrupted. If you have other SQL instances installed (of any version) then depending upon which exact registry entry you deleted they are probably broken as well. While you can try to uninstall any other SQL instances that are listed you will ultimately probably end up having to manually clean them up. This older article provides some help in that. You might first try running the SQL repair of your SQL Express installation and see if that puts things back together enough to run the uninstall program. If not then you'll have to manually remove SQL which is complex and could cause other issues.

    SQL installs services. You'll have to use the command prompt to remove the services that are installed. They all start with MSSQL if I remember correctly. Be sure to stop the services first otherwise you'll have to reboot before they can be removed. You'll need to delete the SQL registry entries keeping in mind that they'll be under both HKLM\Software\Microsoft\Microsoft SQL* and HKLM\Software\wow6432Node\Microsoft. But some third party tooling will also create entries under here so ideally try to figure out which one's seem related to third party and skip them otherwise you'll break the apps.

    Finally you'll need to clean up the file system. SQL will be in a variety of places but for the most part Program Files\Microsoft SQL Server and Program Files (x86)\Microsoft SQL Server are where the instanced files are. Shared components are stored elsewhere but hopefully reinstalling SQL will put them back together.

    Once you've done all that reboot the machine and then try installing SQL Express again.

    1 person found this answer helpful.