How to get a list of all the MS SQL Server instances on the local machine? How to get a list of all the MS SQL Server instances on the local machine? sql-server sql-server

How to get a list of all the MS SQL Server instances on the local machine?


I am able to see both 2005 and 2008 SQL Server instances on my laptop using Powershell:

Get-Service | Where-Object {$_.Name -like 'MSSQL$*'}

Other possibilities to explore include enumerating through the RegisteredServers namespace.


From a command prompt (cmd.exe):

sc query|findstr "DISPLAY_NAME"|findstr /C:"SQL Server (" > myfile.txtFOR /F " tokens=2 delims=()" %i in (myfile.txt) do @echo %computername%\%i


I know this is an older post, but I did come to this post today looking for a way to find installed instances of SQL Server. Although the two answers given are helpful, I think they only pertain to installed and running instances of SQL Server. If SQL Server Configuration Manager is installed, all installed instances should be listed under the SQL Server Services node. Here you might find an instance that is installed, but not running. You can right click the instance and start it. I am sure there are other ways to do this; it is just a way that came in handy for me today and I thought I would share it.