I'm trying to connect to a microsoft SQL database but I dont know its name.

Database Name

I suspect it will be something of the form servername\databasename

It would be good if I could just use SELECT DB_NAME() but since I don't know what its called, I cant run the query in the first place.

I can see that there is a SQL port open in zenmap and when I look at the server I can see that the process is running in the task manager.


When just using the server name I get an error message

A network-related or instance-specific error occurred while establishing a connection to SQL Server. The server was not found or was not accessible. Verify that the instance name is correct and that SQL Server is configured to allow remote connections. (provider: Named Pipes Provider, error: 40 - Could not open a connection to SQL Server) (.Net SqlClient Data Provider)

  • it's server name, you can try your computer name for that, or just servername whatever it is in your case, don't use databasename there. – vijayp Nov 24 '14 at 7:10
  • I should clarify, I know what my server name is, and I've tried putting that in. I think I need the database name as well (servername\databasename) – sav Nov 24 '14 at 7:27
  • I know the server name part is correct because the zenmap scan worked – sav Nov 24 '14 at 7:32

Ok, there are a few things to explain first.

(1) The Connect to Server prompt within the Login properties is only asking for authentication. You cannot specify a database name within the Server Name field of that window in order to connect to it. For the server name you specify either server or server\instance name. You would connect to a specific database by setting this via the Connection Properties tab:

enter image description here

(2) Folks that reference using the <browser for more...> option within the login portion should understand that in a default installation of SQL Server 2012 the Browser service is disabled. So even on a local installation you will not be able to see your server via this method.

Ok, now if you need to find out the "name" of the SQL Server instance you want to connect to you can follow any of the methods below (this is not an exhaustive list, just the most common ones to use):

SQL Server Configuration Manager

Via the Start Menu you would find SQL Server Configuration Manager and open it to look at the Services to see the list of SQL Server components installed on the server. You can also access this, if on the server, via the Computer Management console (you may actually see it show up twice if more than one version of SQL Server is installed, as there is on my machine):

enter image description here enter image description here


A simple one liner can provide the same information you will see in SSCM or the Services Management Console (services.mcs) if you are local to the server:

enter image description here

If you happen to be remote you can try to use this command but it will not work if proper access is not granted: Get-Service *SQL* -Computer Server1

To connect to the instances you find with SSMS if you see the services listed as SQL Server (MSSSQLSERVER) this is a default instance and if you are on the physical server you can use the server name, simply put a period (.), or localhost.

If you find a named instance it will be noted as SQL Server (instance name), as on my machine I have a named instance of SQL14 so I would put localhost\SQL14 since I am on my machine. If I had this on a server and was connecting remotely it would be the actual server name instead of localhost.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.