How can I get a list of installed SQL Server instances?

Today we’ll talk about how we can get a list of locally installed SQL Server instances on a system.   This information is stored in the registry at the following location:

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


If you are looking for 32 bit instances on a 64 bit OS, you will need to look here:

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

All we need to do is query this registry key to get the list of instances installed on a machine.   On my personal machine, I have the following instances installed:


Below are a few ways we can get this information for 64 bit instances on 64 bit Windows:

Command shell “reg.exe” utility:

reg query "HKLM\Software\Microsoft\Microsoft SQL Server\Instance Names\SQL"


In PowerShell:

Get-ItemProperty ‘HKLM:\Software\Microsoft\Microsoft SQL Server\Instance Names\SQL’


In .NET:

RegistryKey baseKey = RegistryKey.OpenBaseKey(RegistryHive.LocalMachine, RegistryView.Registry64);
RegistryKey key = baseKey.OpenSubKey(@"SOFTWARE\Microsoft\Microsoft SQL Server\Instance Names\SQL");

foreach (string s in key.GetValueNames())


If you need to read the registry from another computer, then the RegistryKey class has a “OpenRemoteBaseKey” static method that you can use. 

– Jay

Comments (6)

  1. Phil W says:

    What's the situation when there are 64-bit and 32-bit on an x64 system? Do we query WoW6432 for 32-bit and native registry for 64-bit?

  2. jamesask says:

    @Phil – thanks for catching that.  I should have put this is for 64 bit instances – running on 64 bit Windows.  If you are looking for 32 bit instances on a 64 bit machine, you'll need to look here:

    HKEY_LOCAL_MACHINESOFTWAREWow6432NodeMicrosoftMicrosoft SQL ServerInstance NamesSQL

    I edited the post to note that.

  3. CV says:

    this is good, thanks Jay

  4. SSD says:

    Thank you for answering the question first time, correctly.

  5. DG says:

    it just works for SQL2005 or higher… not for SQL2000

  6. mst says:

    That gets all installed instances; is there a way to show which of those are active? I'm running an active-active SQL2008r2 cluster and it'd be handy to know when both instances are running on a single node.