I can't open SQL Server 2014 "Cannot connect to server" - sql

After setup I can't open my SQL Server Management Studio:
TITLE: Connect to Server
Cannot connect to 0.
ADDITIONAL INFORMATION:
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) (Microsoft SQL Server, Error: 53)
The network path was not found

In my case what it worked for me was the Hosts file in the folder C:\Windows\System32\drivers\etc
I was trying to connect into a SQL server with a name that has an entry in the HOSTS file; however, the IP in the HOSTS file was unreachable - Nonexisting -
First, I connected using my SQL client using the IP address and it was no problem.
Next, I delete the entry for the SQL server name in the HOST file in the folder C:\Windows\System32\drivers\etc, saved it and again tried to connect into that SQL server using the name that I just deleted from the host file and it went thru without issues.
I hope it helps someone along the way

It happened for me, but it is nor serious problem. If database is in your local, may be u must boot IIS or SQLEXPRESS manually in Services of Windows.
And may be, you are writing incorrect name.

You can try the following:
In Windows, go to Services >> SQL Server related to your instance >> Right Click >> Start
Again in Services >> SQL Server AGENT related to your instance >> Right Click >> Start
Try connecting the instance again using SSMS.
Regards,
Pratik

The error message is saying Cannot connect to 0. That 0 is where it would normally give the name of the instance it was trying to connect to. Which implies that you gave it 0 as the name of the SQL instance to connect to, which is never going to work.
You need to give it the name of the machine where the SQL server service has been installed (or use shortcuts like . or localhost to represent the current machine) and if the instance name was not the default instance name, you need to follow the machine name with backslash and the instance name.

If you want to connect to the local instance via SQL Server Management. You can expand the server name box and click the . Then you can browse the local servers via expand the "Database Engine". Please click the instance name which you want to connect so that you can avoid fat figures.
Browse for Servers
Besides, if you want to connect to the default instance on the local computer, please specify the server name as "localhost" or " . ". For detailed information, please refer to the document.
https://learn.microsoft.com/en-us/sql/database-engine/configure-windows/logging-in-to-sql-server?view=sql-server-2017

Related

Can't connect to a SQL server remotely

i'm a new to stackoverflow but maybe i may also ask a question. I also hope i can help others to find solutions regarding their issues.
So, here we go. I moved a database from an old SQL server to a new one. While trying to configure the application to use the new location of that database shows up an error message like this:
Cannot connect to \MSSQLSERVER.
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: SQL Network Interfaces, error: 25 - Connection string is not valid) (Microsoft SQL Server, Error: 87)
The parameter is incorrect
So i started an analysis to solve this issue. And i checked those things:
DNS resolution -> check
ping to the new SQL Server -> check
Firewall disabled -> check
Remote connections on SQL Server enabled -> check
Still receiving this error message. I configured the SSMS on the application server and ran that as SQL server service user without any success.
SQL Server browser is running
TCP/IP is enabled using the default port 1433
I am not sure regarding the SQL server instance name. IMHO it is shown in the service name and the default instance name is MSSQLSERVER. The error message mentions that the connection string is not valid.
So, at this point i don't have any further ideas.
Greetings,
Chris
[EDIT] I don't use any specific connection string because i connect using SSMS.
enter image description here
[EDIT2]
I was able to connect locally using the hostname (not localhost).
All tests below do not use an instance name
Test Result
-----------------------------------------------------
Locally, hostname, AD Auth Success
Remote, hostname, AD Auth The target principal name is incorrect. Cannot generate SSPI context
Remote, FQDN, SQL Auth Connection string is not valid
Step 1: Login Authentication Windows or SQL Server
Check your login Authentication whether its Windows or SQL Server.
Step 2: Use (.) (dot) instead of complete server name
If you are using local MS sql database then you can use (.) (dot) instead of complete server name.
Step 3: Enter Correct Host Name
Enter your correct host name: (hostname\SQLEXPRESS) my_hostname\SQLEXPRESS (in case of SQL Server Express) or (my_hostname\mssqlserver).
Step 4: Try localhost slash () then host name
You can also try localhost slash () then host name, here is sample as (localhost\SQLEXPRESS) or (localhost\mssqlserver).

Not able to connect to local SQL Server 2008

I have just recently downloaded and installed SQL Server 2008 on my laptop. I want to login using my local details.
I tried like this in my image below
but I get this error:
Kindly let me know how to connect it as I am new for doing first time installation.
There are many reasons..few listed below
Instance name may be incorrect..So try searching for all the available instances ..when you are connecting from local ,you can check that easily by try clicking on server name drop down and browse for more and clicking database engines
Once instance name is correct, you can try checking if SQL Server services are running by opening configuration manager
If SQL Server is running , you may want to check if network protocols are enabled in same configuration manager
One more reason could be SQL Server browser service not running..this helps you to connect to right instance when you have multiple instances running on same box and you don't specify port number while connecting
Do the following to troubleshoot:
Go into sql server connection manager and check if sql server services is running. If it is not running then start it.
If it is running, right click it and open it.
Copy name of instance from and paste that name in management studio connection window.
If you still get error try connecting it with ‘.’ In server name in ssms connection window.
If its still not working, go in sql server connection manager and check protocols. Check if named pipe protocol is enabled. If not enabled, enable named pipe protocol.
If you follow above steps you should fix the error you are getting.

How to connect to sql server database via LAN

want to connect to a database on another PC connected via LAN. I am able to use the sql server db with string like C:\Users... but i cannot connect using string like (\\Server\c\user...) I tried to move the db file to My Documents, still i get this error.
I get the following error message: An attempt to attach an auto-names database for file (\\SERVER\Users\Jeswills\Documents\TBSDB.mdf) failed. A database with the same name exists, or specified file cannot be opened, or it is located on UNC share
I hope i asked the question correctly
As database does not support the '\SERVER\c...' parameters, i had to attach the database, after enabling TCP/IP and SQL Browser, i had to create a login through security and add it to the attached database file because authentication must be SQL not windows. And i also gave read/write privileges to the account. Then on the child system, i confirmed connection to the account through SSMS with the login connecting to SERVER (which is the remote computer's name).
Note: you must be able to ping the remote systems and SQL Server Express R2 installed. I tried with SQL Server Express but did not get a head way. www.connectionstrings.com/sql-server-2008 for more connection string
Then i used this connection string to connect remotely, making integrated security and user instance = false unlike if i were connecting locally.
Data Source=SERVER\SQLEXPRESS,1433;Database=DATABASEFILE.MDF;Integrated Security=False;Network Library=dbmssocn;Connect Timeout=30;User Instance=False;user='USERNAME';password='PASSWORD'
Not sure what specifically you’re trying to do here but I guess it’s one of these two.
Option 1
Attach database stored on remote shared drive to a local SQL Server
Note that this is only possible starting in SQL Server 2008 R2. If you’re running SQL Server 2008 this is not an option.
Check this for more details
http://blogs.msdn.com/b/varund/archive/2010/09/02/create-a-sql-server-database-on-a-network-shared-drive.aspx
Option 2
Connect to remote SQL Server instance from local computer
If that database is already attached to SQL Server instance that runs on the same machine then it’s much better to just connect to that instance from SSMS than trying to attach database from remote storage.
To do this you need to enable TCP/IP protocol in SQL Server Configuration Manager. It’s under SQL Server Network configuration node. Make sure you enable TCP/IP and also set enable the IP address for listening (this is under TCP/IP properties).
Apart from this you’ll want to enable remote connections on your remote instance. This is done from SSMS -> instance properties -> Connection tab
When this is done you should be able to connect to remote instance from local SSMS by typing in IPaddress/instance name. For example 192.168.0.125/{instance_name} or only IP address if this is default instance.

Cannot connect to sqlexpress

I just installed of SQL Server Management Studio Express 2012, and then I try to connect database engine with servername : ./sqlexpress, but it failed.
Its raised message like below :
TITLE: Connect to Database Engine
Cannot connect to ./sqlexpress.
ADDITIONAL INFORMATION:
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) (Microsoft SQL Server, Error: 3)
For help, click: http://go.microsoft.com/fwlink?ProdName=Microsoft%20SQL%20Server&EvtSrc=MSSQLServer&EvtID=3&LinkId=20476
The system cannot find the path specified.
Whats going wrong?
I've seen this in the past, most likely the wrong instance name or address. Since it is a local DB instance on your machine you will want to try connecting to (local)\SQLEXPRESS [This is the default SQL Express Instance]
If you are running a local instance of SQL Server you can just use localhost as the server name. Also you can try to remove the ./ before the server name.
If anyone else gets a failed to connect to server instance while trying to connect to a DB in C#, make sure you add localhost to the front of your database server address if you're on the same machine.
ie: myDatabase2012
should be put in as localhost\\myDatabase2012 (the second \ is needed to escape the first)

When trying to access a SQL Server 2008 server in my domain, I get a "server not found or was not accessible" error

When setting up a system that requires a remote computer to access SQL 2008 stored on another computer in the same domain, I'm running into the following error:
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.
When I installed SQL Server, I was sure I set up the system just so. How can I troubleshoot this?
I appreciate this thread is old now and already has an accepted answer, but I found a slightly different solution with regards to this issue that others may find useful. From reading this issue description I found that there were two SQL Server services in the standard Windows Local Services control panel: MSSQLSERVER and SQLEXPRESS (see below).
I found that SQLEXPRESS was running, but MSSQLSERVER was not. So I simply started that service, and I was able to connect to SQL Server again.
A couple of things to try...
check the Configuration settings to ensure that the TCP protocol is enabled.
try accessing the remote server via IP instead of the server name, this has worked for me in the past (oddly).
I'm assuming its running on the default port, if it isnt then you will need to specify the port number after the server-name / ip separated by a comma:
sql-server-name,{port}
Look at the name of the SQL server instance and make sure it is what you are using to connect to it. Also, look at the SQL Server Network Configuration under Configuration Tools. I worte an article about a very similar problem (if not the same) here:
Having had this a few times even with named pipes the first thing I always try is pre-pending the server name before the named instance; so SERVER\namedinstance. You can manually overwrite the dropdown values in the connect . So ideally in the setup it should have a brief tip below the named instance box like Enter SERVER\namedinstance. Although knowing MS if you entered this you'd probably end up with SERVER\SERVER\namedinstance...!
You can also use the browse option (bottom of server dropdown) and if you're lucky it may be in the 2nd tab (Network Servers) - even if it's a local install.
The program you are running needs to be running under an account which has access to the network (and depending on protocol chosen, may need access to the SQL Server by role or whatever). This error indicates that it is not finding the server on the network by name or IP.
The most common case I have seen this is when you have a web app running under a local account which does not have network access attempting to access SQL Server on another machine.
If you have access to the server that SQL Server is running on, you can try:
-Opening SQL Server Configuration Manager
-In the left pane, click 'SQL Server Network Configuration' and then 'Protocols for [instance name, possibly SQLEXPRESS]'
-Right click TCP/IP again and you'll see the port used. Mine was listed under IPAll/TCP Dynamic Port.
-In SQL Server Management studio add the port name to your connection string as follows:
if you were connecting to:
MYSERVER\SQLEXPRESS
the port is specified as
MYSERVER,2071\SQLEXPRESS