Attempt to execute sqlcmd failed, connection failed?

When I try to run sqlcmd (from the cmd prompt), I get the following error:

HResult 0x2, Level 16, State 1 Named Pipes Provider: Failed to open a connection to SQL Server [2]. Sqlcmd: error: Microsoft SQL Server 10.0 native client: connected to the network or an error occurred while establishing a connection to SQL Server, the server was not found or is unavailable. Verify that the instance name is correct and I'm configured with SQL Server for a remote connection. For more information, see SQL Server Books Online. Sqlcmd: Error: Microsoft SQL Server Native Client 10.0: Login timed out.

Not sure why this is happening? I can connect to the sql server from my asp.net website (which runs locally, such as a database), but sqlcmd cannot connect.

+7
sql-server sqlcmd
source share
2 answers

Try sqlcmd -S <InstanceName>

  • Your team will only work if you installed the server as the default instance.
  • Run sp_helpserver to find out the name of the instance.
+10
source share

If you are not using the default instance, try the following command:

 sqlcmd -S MACHINENAME\INSTANCE_NAME 

Pay attention to the capital S. Also note that I did not give him a password, given that sqlcmd authentication is auth by default, so I can log in as the current user. For more information from Microsoft, check this> http://msdn.microsoft.com/en-us/library/ms165702.aspx

+7
source share

All Articles