Can't connect to SQL Server Express using sqlcmd.exe - sql-server

Env.: Vista SP1, SQL Server Express 2005
I'm able to connect to my localhost SQL Server using SQL Server Management Studio, using Windows authentication and, to the best of my knowledge, all default parameters, including network protocol.
Now I try to connect using sqlcmd.exe to no avail:
C:\Program Files\Microsoft SQL Server\90\Tools\Binn>sqlcmd -S \\PCSERGEHOME\SQLE
XPRESS
HResult 0x57, Level 16, State 1
Named Pipes Provider: Invalid parameter(s) found [87].
Sqlcmd: Error: Microsoft SQL Native Client : An error has occurred while establi
shing a connection to the server. When connecting to SQL Server 2005, this failu
re may be caused by the fact that under the default settings SQL Server does not
allow remote connections..
Sqlcmd: Error: Microsoft SQL Native Client : Login timeout expired.
I also tried to use -U PCSERGEHOME\Serge. I'm then prompted for my password but the result is the same.
TIA for your help.

Lose the leading \\
Actually, try .\XPRESS (period slash instance)

Try
Disabling the firewall
Using localhost instead
Check the Server setup (in management studio) to make sure remote connections are enabled
Check the settings in Surface Area configuration and make sure all the transports are enabled and remote connections are enabled

Related

Not able to login to sql server

I am not able to login to sql server 2012
error
Sqlcmd: Error: Microsoft SQL Server Native Client 11.0 : Named Pipes Provider: C
ould not open a connection to SQL Server [67]. .
Sqlcmd: Error: Microsoft SQL Server Native Client 11.0 : Login timeout expired.
Sqlcmd: Error: Microsoft SQL Server Native Client 11.0 : A network-related or in
stance-specific error has occurred while establishing a connection to SQL Server
. Server is not found or not accessible. Check if instance name is correct and i
f SQL Server is configured to allow remote connections. For more information see
SQL Server Books Online..
Command I am using to login "sqlcmd -S MSSQLSERVER -E"
I also tried enabling TCP/IP under sql server configuration manager.
Thanks
If you are are running the SQLCMD from the machine where the SQL Server is installed, you need to use the below command.
SQLCMD -E
If the SQL Server is on another machine, you need to use the below command. The <ServerName> is the machine name, but not the instance name.
SQLCMD -E -S <ServerName>
You need to check if SQL Server is running or not. Press Win + R and enter services.msc and press enter. (You need to do it on the machine where SQL Server is installed)
This will open the Services window. Scroll through and find SQL Server (MSSQLSERVER) and select it.
On the left side of it, you should be able to see the status. Check if the process is already running or now. If not, you need to start it before using the SQL Server.
If the SQL Server is up and running, you need to check if SQL Server is accessible from your machine. You can check it by executing below command from cmd prompt.
TELNET <ServerName> 1433
If this command does not give you any error, and opens a blank window, that means you are able to reach SQL Server machine. This will rule out any firewall issues. All you need to check is if the SQL Server instance is running or not.

Unable to connect to SQL Server 2008 R2 instance with management studio

I have SQL Server 2008 R2 installed on my PC running Win 7 x64. I used to use it every day with a connection from management studio (Windows Authentication). But, for some reason, management studio is not accepting my connection anymore after I installed DB2 on the same PC.
I know that the instance is not broken since I am able to connect well with Visual Studio 2010 where I also tried creating new DB, inserting records etc.
How do I mend this problem with management studio? How might installing DB2 have affected Management Studio?
I am getting following error:
TITLE: Browse Server for Database
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: 26 - Error Locating Server/Instance
Specified) (Microsoft SQL Server, Error: -1)
For help, click:
http://go.microsoft.com/fwlink?ProdName=Microsoft+SQL+Server&EvtSrc=MSSQLServer&EvtID=-1&LinkId=20476
It's not an authentication issue, as you would get a different error. If this is a named instance, you need to ensure the SQL Server Browser service is started.
I'm guessing you also have TCP/IP protocol enabled?
I don't know much about DB2 but maybe there is some conflict with the ports used. By default SQL Server uses 1433 for the default instance, and 1434 for SQL Browser to dynamically allocate a port for named instances. Check these to make sure they are still good.
Make sure that you have port opened on target server.
Use Telnet (install from Control Panel -> Turn Windows features On of Off)
>telnet <server-ip/name> 1433
or network scanner from nmap.org
>nmap -sT -r -n -vv -p1433 <server-ip/name>

Allow SQL Server Remote Connection

I need to connect to remote SQL Server by an ip address with a port.
But when I ping to the ip address then that reply as well. But when I try to establish the connection that failed.
I tried with Management Studio and with command prompt too.
My command was:
sqlcmd -S [IP],[port] -U [user] -P [password]
The error report as follows :
HResult 0x274C, Level 16, State 1
TCP Provider: A connection attempt failed because the connected party did not
properly respond after a period of time, or established connection failed because
connected host has failed to respond.
Sqlcmd: Error: Microsoft SQL Server Native Client 10.0 : A network-related or
instance-specific error has occurred while establishing a connection to SQL Server.
Server is not found or not accessible. Check if instance name is correct and if
SQL Server is configured to allow remote connections. For more information see
SQL Server Books Online..
Sqlcmd: Error: Microsoft SQL Server Native Client 10.0 : Login timeout expired.
I would like to know that
is there any missing steps from my client side for which I am unable to establish the connection?
or this is the matter of server configuration (Allowing remote connection)
It looks like you are actually missing the database name you would like to connect to:
EX: sqlcmd -S [IP],[port]\[DBNAME] -U [user] -P [password]
In addition to configuring the Windows Firewall to allow incoming connections on TCP Port 1433, you will need to start the SQL Server Browser service. This service can be found on the Start Menu - Microsoft SQL Server 2008 R2 - Configuration Tools - SQL Server Configuration Manager. Once there, click SQL Server Services on the left, then SQL Server Browser on the right. This is disabled by default.
Right click SQL Server Browser and choose Properties
Click the Service Tab
For property Start Mode, choose Automatic
Click Apply
Click the Log On tab
Choose the appropriate account for log on (I used built in service account)
Click Apply
Click Start
Click OK
This solved my problem on Windows Server 2008 R2 with SQL Server 2008 R2 Express Edition.
Check the firewall settings on the server that is actively hosting the database. By default, Windows Server will block all remote connections to the Database Server.

SQL Server Login Using OSQL.exe

From Visual Studio 2010 I can connect to my SQL Server Express 2005 instance - by specifying windows authentication. However, when I use a command like it doesn't work:
C:\Program Files (x86)\Microsoft Visual Studio 10.0\VC>osql -S SQLEXPRESS -U Quixote
nt -P Password.0
[SQL Native Client]Named Pipes Provider: Could not open a connection to SQL
Server [53].
[SQL Native Client]Login timeout expired
[SQL Native Client]An error has occurred while establishing a connection to
the server. When connecting to SQL Server 2005, this failure may be caused by
the fact that under the default settings SQL Server does not allow remote
connections.
Incidentally, the above does not actually list my windows name and password - I just substituted examples. What am I doing wrong?
You cannot use -U and -P if you want to connect with windows authentication. That is for SQL authentication. Use -E instead:
osql -S SQLEXPRESS -E
SQL Server 2005 provides several network protocols (like Shared Memory, TCP/IP, named pipes, etc.) (http://msdn.microsoft.com/en-us/library/ms187892(v=sql.90).aspx)
Maybe you only have Shared Memory enabled (which your VS is using), and the command line needs a named pipe or TCP/IP to connect.
So, try enabling the other protocols, through the SQL Server Configuration Manager, as described here:
http://support.microsoft.com/kb/914277/en-us

Error while connecting to external SQL Server with an IP using SQL Management Studio 2005

Error while connecting to external SQL Server IP using SQL Management Studio 2005 address
TITLE: Connect to Server
Cannot connect to 1.2.3.4\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: SQL Network
Interfaces, error: 26 - Error Locating
Server/Instance Specified) (Microsoft
SQL Server, Error: -1)
For help, click: http://go.microsoft.com/fwlink?ProdName=Microsoft+SQL+Server&EvtSrc=MSSQLServer&EvtID=-1&LinkId=20476
By default, SQL Server 2005 doesn’t allow remote connection so you have to enable it manually. So if #abatishchev's solution doesn't get you going; it may be you haven't set the permissions to connect.
Run the Surface Area Configuration Manager (it should be in the SQL Server folder in My Programs under Configuration Tools).
Choose Surface Area Configuration for Services and Connections
Select your server expand database engine and then remote connections and enable TCP/IP and / or tcp/ip and named pipes. Click Apply.
Whilst you are here check the SQL Server Browser is set to run. Expand it out and choose the service; change the startup type to be Automatic.
Try again in management studio express to connect to the machine.
Make sure that remote server allows connection to port 1433/tcp, e.g.:
using telnet client (in Windows 7 isn't installed by default, to install use Turn Windows features):
telnet 1.2.3.4 1433
or using nmap (port scanner)
nmap -sT -r -n -vv -p1433 1.2.3.4
If doesn't allow - check inbound firewall rules.

Resources