Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

SQLCMD fails with login timeout expired.

1,446 views
Skip to first unread message

Morris Neuman

unread,
Jul 11, 2007, 6:56:00 PM7/11/07
to
My system is running XP Pro ver 2002 SP2 and I have SQL2000 and
SQL2005Express installed. When I run SQLCMD from a Command Prompt I get an
error:
Hresult 0x2, level 16, State 1
Named pipes Provider: could not open a connection to SQL Server [2].
Then a lengthy message that an error occurred and finally
Sqlcmd; Error: Microsoft SQL Native Client : Login timeout expired.

I have the 2005 server management studio and see the two instances of the
SQL servers and have tried it with one or the other and both servers running,
all get the same message.

I am logged in to a local user account with admin privileges.

How can I correct this so I get the Sqlcmd prompt.
--
Thanks
Morris

Peter YangMSFT]

unread,
Jul 12, 2007, 1:02:29 AM7/12/07
to
Hello Morris,

I understand tht you could connect to SQL Express properly by 2005
management tool but you cannot connect it via sqlcmd. If I'm off-base,
please let me know.

First I'd like to know the following information before we go further:

1. By using SQL 2005 configuration manager, please check if both TCPIP and
Named Pipes are enabled for SQL Express instance. Also, please make sure
SQLBrowser service is running

2. In Configuration manager, please make sure TCPIP and named pipes
protocals are enabled properly for SQL client.

3. Please check the errorlog for the sql express instance and make sure
TCPIP and Named pipes are enabled. You shall also see the port for

C:\Program Files\Microsoft SQL Server\MSSQL.x\MSSQL\LOG

4. Try different protocols by using SQLCMD to test

sqlcmd -S np:\\127.0.0.1\pipe\MSSQL$instancename\sql\query
sqlcmd -S tcp:servername\instancename
sqlcmd -S tcp:servername\instancename,portnumber

Note: You may need to change the servername, instancename, portnumber
properly according to your server configurations.

If you have any update, please feel free to let's know. Thank you.

Best Regards,

Peter Yang
MCSE2000/2003, MCSA, MCDBA
Microsoft Online Community Support
==================================================
Get notification to my posts through email? Please refer to
http://msdn.microsoft.com/subscriptions/managednewsgroups/default.aspx#notif
ications
<http://msdn.microsoft.com/subscriptions/managednewsgroups/default.aspx>.
Note: The MSDN Managed Newsgroup support offering is for non-urgent issues
where an initial response from the community or a Microsoft Support
Engineer within 1 business day is acceptable. Please note that each follow
up response may take approximately 2 business days as the support
professional working with you may need further investigation to reach the
most efficient resolution. The offering is not appropriate for situations
that require urgent, real-time or phone-based interactions or complex
project analysis and dump analysis issues. Issues of this nature are best
handled working with a dedicated Microsoft Support Engineer by contacting
Microsoft Customer Support Services (CSS) at
<http://msdn.microsoft.com/subscriptions/support/default.aspx>.
==================================================
This posting is provided "AS IS" with no warranties, and confers no rights.


Erland Sommarskog

unread,
Jul 12, 2007, 4:53:38 AM7/12/07
to
Morris Neuman (Mor...@online.nospam) writes:
> My system is running XP Pro ver 2002 SP2 and I have SQL2000 and
> SQL2005Express installed. When I run SQLCMD from a Command Prompt I get
> an error:
> Hresult 0x2, level 16, State 1
> Named pipes Provider: could not open a connection to SQL Server [2].
> Then a lengthy message that an error occurred and finally
> Sqlcmd; Error: Microsoft SQL Native Client : Login timeout expired.

First: when you have a problem that includs an error message, make it a
habit, to *always* include the full error message. There may be information
in the error message that makes it easier to resolve the issue.



> I have the 2005 server management studio and see the two instances of
> the SQL servers and have tried it with one or the other and both servers
> running, all get the same message.

Can you or can you not connect to your SQL Server instances from Mgmt
Studio?

Could you post the exact command lines for SQLCMD that you tried?

If you try to connect from Mgmt Studio, more exactly what do you? New
Query from Registered Servers or something else?

Since you have SQL 2000, do you also have the SQL 2000 tools installed?
Can you connect from Query Analyzre?

Your SQL 2000 instance is that a default instance or a named instance?

Have you check in SQL Configuration Manager that the client protocols
match the server protocols?


--
Erland Sommarskog, SQL Server MVP, esq...@sommarskog.se

Books Online for SQL Server 2005 at
http://www.microsoft.com/technet/prodtechnol/sql/2005/downloads/books.mspx
Books Online for SQL Server 2000 at
http://www.microsoft.com/sql/prodinfo/previousversions/books.mspx

Morris Neuman

unread,
Jul 12, 2007, 3:38:05 PM7/12/07
to
Peter
Thanks for your reply. I tried it with the -S np: option and that worked.

But none of the -S tcp: options worked. There I would get the error msg:
"Connection string is not valid [87]." and again "login TImeout expired".

I can use it with the -np option but it would be good to know why the -tcp
option fails with that msg.
Any insight would be appreciated.
Thank you
--
Thanks
Morris

Morris Neuman

unread,
Jul 12, 2007, 3:42:08 PM7/12/07
to
Erland
Thank you for your response. I am able to get connected with Peter's
suggestion of using -S np: option. see my response to him.
I can connect with the visual tools.

--
Thanks
Morris

Peter YangMSFT]

unread,
Jul 12, 2007, 11:31:19 PM7/12/07
to
Hello Morris,

First I'd like to confirm the instance name of the server. Is it
SQLExpress? If so, you shall use instance name 'Sqlservername\SQLEXPRESS'.
Please note sqlservername shall be the compupter name of your server.

It seems that you don't have TCPIP enabled for the instance. Did you check
the server confgiruation for the instance.

Also, please check the errorlog and make sure TCPIP is actually enabled:

C:\Program Files\Microsoft SQL Server\MSSQL.x\MSSQL\LOG\errorlog

For exmaple, check if there is a line like following:

2007-07-12 03:17:05.25 Server Server is listening on [ 'any' <ipv4>
3167].

Is the SQLbrowser service running properly?

If the issue still occurs, please send the errorlog to me, and please
remove Online from my displayed email address.

I look forward to your update. Thank you.

Best Regards,

Peter Yang
MCSE2000/2003, MCSA, MCDBA

Microsoft Online Partner Support

When responding to posts, please "Reply to Group" via your newsreader so
that others may learn and benefit from your issue.

=====================================================

Peter YangMSFT]

unread,
Jul 16, 2007, 11:26:51 PM7/16/07
to
Hello Morris,

I'm still interested in this issue. If you have any comments or questions,
please feel free to let's know. We look forward to hearing from you.

Morris Neuman

unread,
Jul 18, 2007, 4:46:02 PM7/18/07
to
The instance name is SQLExpress for the SQL 2005 and SQL2000MN for the SQL
2000 server (both on the same computer).
I sent you an email with the logs
--
Thanks
Morris

Peter YangMSFT]

unread,
Jul 18, 2007, 11:54:51 PM7/18/07
to
Hello Morris,

Thank you for your reply and additional information!

From SQL 2000 error log, it's not listening on TCPIP:

2007-07-18 16:02:06.51 server SQL server listening on Shared Memory,
Named Pipes.

From 2005 Express instance log, it listens on port 1900:

2007-07-18 16:06:17.62 Server Server is listening on [ 'any' <ipv4>
1900].
2007-07-18 16:06:17.62 Server Server local connection provider is
ready to accept connection on [ \\.\pipe\SQLLocal\SQLEXPRESS ].
2007-07-18 16:06:17.62 Server Server named pipe provider is ready to
accept connection on [ \\.\pipe\MSSQL$SQLEXPRESS\sql\query ].
2007-07-18 16:06:17.62 Server Server is listening on [ 127.0.0.1
<ipv4> 2107].


I suggest that you try the following sqlcmd command to connect to the SQL
Express instance:

sqlcmd -S tcp: DELL4600C\SQLEXPRESS, 1900

If above command works, please make sure SQL browser service is started and
running properly.

Also You may want to run SQL Configuration manager if it's installed on
your machine:

Under SQL native client configuration->Client Protocols, and make sure
TCPIP is enabled.

Morris Neuman

unread,
Jul 19, 2007, 10:08:02 AM7/19/07
to
OK that worked for SQl2005. BTW you can't have spaces in the sqlcmd
parameter so its tcp:dell4600c\sqlexpress,1900

But the ques. now is I used the SQL2000 server network utility and on the
General tab there are no protocols listedin either the Disabled or Enabled
protocols. I gues thats why itsnot listening on TCP. How can I fix that to
get TCP listed and enabled?
--
Thanks
Morris

Morris Neuman

unread,
Jul 19, 2007, 10:44:01 AM7/19/07
to
Besides showing the Browser Service as "Started" in the Services window how
do I know it is running properly? And does that apply to both SQL 2000 and
2005?
--
Thanks
Morris

Rick Byham, (MSFT)

unread,
Jul 19, 2007, 11:56:30 AM7/19/07
to
One possibility - When you open the Server Network Utility, you may be
looking at the SQL Server 2005 instance. In the Instance(s) on this server:
box, select the SQL Server 2000 instance.
--
Rick Byham (MSFT)

This posting is provided "AS IS" with no warranties, and confers no rights.

"Morris Neuman" <Mor...@online.nospam> wrote in message
news:E66041B1-DB37-485C...@microsoft.com...

Morris Neuman

unread,
Jul 19, 2007, 1:02:01 PM7/19/07
to
No Im sure I have the 2000 one selected and why would no protocols be listed
then? since 2005 is listening on tcp 1900.

Im doing a reinstall of SQl2000 to see if that fixes it.

--
Thanks
Morris

Peter YangMSFT]

unread,
Jul 19, 2007, 11:51:45 PM7/19/07
to
Hello Morris,

It seems some protocol related registry keys might be corrupted or missing.
I agree reinstall SQL 2000 instance might be helpful. Also, I notice that
you only have RTM installed, it's suggested that you upgrade to SQL 2000
SP4 to see if the issue still occurs.

http://www.microsoft.com/downloads/details.aspx?familyid=8e2dfc8d-c20e-4446-
99a9-b7f0213f8bc5

Peter YangMSFT]

unread,
Jul 23, 2007, 11:49:00 PM7/23/07
to
Hi Morris,

Any update on this issue? If you have further questions, please feel free
to post back.

sachin lad

unread,
Jan 16, 2008, 5:24:31 AM1/16/08
to

hello to all members of this group.
I am sachin lad working as a software developer in company.
I am currently working in windows ce.
I have some queries that while i am connecting the pda throgh my machine
through wireless then i am getting some error like sql server not found.
If anybody works on this type then please reply me as early as possible.

Regards,
Sachin Lad
Software engineer.

*** Sent via Developersdex http://www.developersdex.com ***

sheikhmunawar

unread,
Apr 7, 2010, 6:38:30 PM4/7/10
to
command which iam running is

DECLARE @user nvarchar(100);
SET @user ='NT AUTHORITY\Local Service';

USE [master]

IF NOT EXISTS (SELECT * FROM sys.server_principals WHERE name = @user)
EXEC ('CREATE LOGIN ['+ @user+'] FROM WINDOWS WITH DEFAULT_DATABASE=[master]')

EXEC ('GRANT ALTER TRACE TO [' +@user+']')

USE [SSAS2008SBS]

EXEC sp_addrolemember 'db_owner', @user
GO


and the errors....


HResult 0x2, Level 16, State 1
Named Pipes Provider: Could not open a connection to SQL Server [2].
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.

and

HResult 0x2, Level 16, State 1
Named Pipes Provider: Could not open a connection to SQL Server [2].
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.


sachin lad wrote:

hello to all members of this group.

16-Jan-08

Previous Posts In This Thread:

On Wednesday, July 11, 2007 6:56 PM
Morri wrote:

SQLCMD fails with login timeout expired.


My system is running XP Pro ver 2002 SP2 and I have SQL2000 and
SQL2005Express installed. When I run SQLCMD from a Command Prompt I get an
error:
Hresult 0x2, level 16, State 1
Named pipes Provider: could not open a connection to SQL Server [2].
Then a lengthy message that an error occurred and finally
Sqlcmd; Error: Microsoft SQL Native Client : Login timeout expired.

I have the 2005 server management studio and see the two instances of the

SQL servers and have tried it with one or the other and both servers running,
all get the same message.

I am logged in to a local user account with admin privileges.

How can I correct this so I get the Sqlcmd prompt.
--
Thanks
Morris

On Thursday, July 12, 2007 1:02 AM
peter wrote:

Hello Morris,I understand tht you could connect to SQL Express properly by
Hello Morris,

I understand tht you could connect to SQL Express properly by 2005
management tool but you cannot connect it via sqlcmd. If I'm off-base,
please let me know.

First I'd like to know the following information before we go further:

1. By using SQL 2005 configuration manager, please check if both TCPIP and
Named Pipes are enabled for SQL Express instance. Also, please make sure
SQLBrowser service is running

2. In Configuration manager, please make sure TCPIP and named pipes
protocals are enabled properly for SQL client.

3. Please check the errorlog for the sql express instance and make sure
TCPIP and Named pipes are enabled. You shall also see the port for

C:\Program Files\Microsoft SQL Server\MSSQL.x\MSSQL\LOG

4. Try different protocols by using SQLCMD to test

sqlcmd -S np:\\127.0.0.1\pipe\MSSQL$instancename\sql\query
sqlcmd -S tcp:servername\instancename
sqlcmd -S tcp:servername\instancename,portnumber

Note: You may need to change the servername, instancename, portnumber
properly according to your server configurations.

If you have any update, please feel free to let's know. Thank you.

Best Regards,

Peter Yang
MCSE2000/2003, MCSA, MCDBA

Microsoft Online Community Support
==================================================
Get notification to my posts through email? Please refer to
http://msdn.microsoft.com/subscriptions/managednewsgroups/default.aspx#notif
ications
<http://msdn.microsoft.com/subscriptions/managednewsgroups/default.aspx>.
Note: The MSDN Managed Newsgroup support offering is for non-urgent issues
where an initial response from the community or a Microsoft Support
Engineer within 1 business day is acceptable. Please note that each follow
up response may take approximately 2 business days as the support
professional working with you may need further investigation to reach the
most efficient resolution. The offering is not appropriate for situations
that require urgent, real-time or phone-based interactions or complex
project analysis and dump analysis issues. Issues of this nature are best
handled working with a dedicated Microsoft Support Engineer by contacting
Microsoft Customer Support Services (CSS) at
<http://msdn.microsoft.com/subscriptions/support/default.aspx>.
==================================================

This posting is provided "AS IS" with no warranties, and confers no rights.

On Thursday, July 12, 2007 3:38 PM
Morri wrote:

RE: SQLCMD fails with login timeout expired.


Peter
Thanks for your reply. I tried it with the -S np: option and that worked.

But none of the -S tcp: options worked. There I would get the error msg:
"Connection string is not valid [87]." and again "login TImeout expired".

I can use it with the -np option but it would be good to know why the -tcp
option fails with that msg.
Any insight would be appreciated.
Thank you

--
Thanks
Morris


""Peter YangMSFT]"" wrote:

On Thursday, July 12, 2007 3:42 PM
Morri wrote:

ErlandThank you for your response.


Erland
Thank you for your response. I am able to get connected with Peter's
suggestion of using -S np: option. see my response to him.
I can connect with the visual tools.

--
Thanks
Morris


"Erland Sommarskog" wrote:

On Thursday, July 12, 2007 11:31 PM
peter wrote:

Hello Morris,First I'd like to confirm the instance name of the server.
Hello Morris,

First I'd like to confirm the instance name of the server. Is it
SQLExpress? If so, you shall use instance name 'Sqlservername\SQLEXPRESS'.
Please note sqlservername shall be the compupter name of your server.

It seems that you don't have TCPIP enabled for the instance. Did you check
the server confgiruation for the instance.

Also, please check the errorlog and make sure TCPIP is actually enabled:

C:\Program Files\Microsoft SQL Server\MSSQL.x\MSSQL\LOG\errorlog

For exmaple, check if there is a line like following:

2007-07-12 03:17:05.25 Server Server is listening on [ 'any' <ipv4>
3167].

Is the SQLbrowser service running properly?

If the issue still occurs, please send the errorlog to me, and please
remove Online from my displayed email address.

I look forward to your update. Thank you.

Best Regards,

Peter Yang
MCSE2000/2003, MCSA, MCDBA
Microsoft Online Partner Support

When responding to posts, please "Reply to Group" via your newsreader so
that others may learn and benefit from your issue.

=====================================================


This posting is provided "AS IS" with no warranties, and confers no rights.

On Sunday, July 15, 2007 10:17 AM
Erland Sommarskog wrote:

Re: SQLCMD fails with login timeout expired.
Morris Neuman (Mor...@online.nospam) writes:

First: when you have a problem that includs an error message, make it a
habit, to *always* include the full error message. There may be information
in the error message that makes it easier to resolve the issue.

Can you or can you not connect to your SQL Server instances from Mgmt
Studio?

Could you post the exact command lines for SQLCMD that you tried?

If you try to connect from Mgmt Studio, more exactly what do you? New
Query from Registered Servers or something else?

Since you have SQL 2000, do you also have the SQL 2000 tools installed?
Can you connect from Query Analyzre?

Your SQL 2000 instance is that a default instance or a named instance?

Have you check in SQL Configuration Manager that the client protocols
match the server protocols?


--
Erland Sommarskog, SQL Server MVP, esq...@sommarskog.se

On Monday, July 16, 2007 11:26 PM
peter wrote:

Hello Morris,I'm still interested in this issue.
Hello Morris,

I'm still interested in this issue. If you have any comments or questions,
please feel free to let's know. We look forward to hearing from you.

Best Regards,

Peter Yang
MCSE2000/2003, MCSA, MCDBA
Microsoft Online Partner Support

When responding to posts, please "Reply to Group" via your newsreader so
that others may learn and benefit from your issue.

=====================================================

This posting is provided "AS IS" with no warranties, and confers no rights.

On Wednesday, July 18, 2007 4:46 PM
Morri wrote:

The instance name is SQLExpress for the SQL 2005 and SQL2000MN for the SQL
The instance name is SQLExpress for the SQL 2005 and SQL2000MN for the SQL
2000 server (both on the same computer).
I sent you an email with the logs

--
Thanks
Morris


""Peter YangMSFT]"" wrote:

On Wednesday, July 18, 2007 11:54 PM
peter wrote:

Hello Morris,Thank you for your reply and additional information!
Hello Morris,

Thank you for your reply and additional information!

From SQL 2000 error log, it's not listening on TCPIP:

2007-07-18 16:02:06.51 server SQL server listening on Shared Memory,
Named Pipes.

From 2005 Express instance log, it listens on port 1900:

2007-07-18 16:06:17.62 Server Server is listening on [ 'any' <ipv4>
1900].
2007-07-18 16:06:17.62 Server Server local connection provider is
ready to accept connection on [ \\.\pipe\SQLLocal\SQLEXPRESS ].
2007-07-18 16:06:17.62 Server Server named pipe provider is ready to
accept connection on [ \\.\pipe\MSSQL$SQLEXPRESS\sql\query ].
2007-07-18 16:06:17.62 Server Server is listening on [ 127.0.0.1
<ipv4> 2107].


I suggest that you try the following sqlcmd command to connect to the SQL
Express instance:

sqlcmd -S tcp: DELL4600C\SQLEXPRESS, 1900

If above command works, please make sure SQL browser service is started and
running properly.

Also You may want to run SQL Configuration manager if it's installed on
your machine:

Under SQL native client configuration->Client Protocols, and make sure
TCPIP is enabled.

Best Regards,


Peter Yang
MCSE2000/2003, MCSA, MCDBA
Microsoft Online Partner Support

When responding to posts, please "Reply to Group" via your newsreader so
that others may learn and benefit from your issue.

=====================================================


This posting is provided "AS IS" with no warranties, and confers no rights.

On Thursday, July 19, 2007 10:08 AM
Morri wrote:

OK that worked for SQl2005.
OK that worked for SQl2005. BTW you can't have spaces in the sqlcmd
parameter so its tcp:dell4600c\sqlexpress,1900

But the ques. now is I used the SQL2000 server network utility and on the
General tab there are no protocols listedin either the Disabled or Enabled
protocols. I gues thats why itsnot listening on TCP. How can I fix that to
get TCP listed and enabled?
--
Thanks
Morris


""Peter YangMSFT]"" wrote:

On Thursday, July 19, 2007 10:44 AM
Morri wrote:

Besides showing the Browser Service as "Started" in the Services window how do
Besides showing the Browser Service as "Started" in the Services window how
do I know it is running properly? And does that apply to both SQL 2000 and
2005?

--
Thanks
Morris


""Peter YangMSFT]"" wrote:

On Thursday, July 19, 2007 11:56 AM


Rick Byham, \(MSFT\) wrote:

One possibility - When you open the Server Network Utility, you may be looking
One possibility - When you open the Server Network Utility, you may be
looking at the SQL Server 2005 instance. In the Instance(s) on this server:
box, select the SQL Server 2000 instance.
--
Rick Byham (MSFT)

This posting is provided "AS IS" with no warranties, and confers no rights.

"Morris Neuman" <Mor...@online.nospam> wrote in message
news:E66041B1-DB37-485C...@microsoft.com...

On Thursday, July 19, 2007 1:02 PM
Morri wrote:

No Im sure I have the 2000 one selected and why would no protocols be listed
No Im sure I have the 2000 one selected and why would no protocols be listed
then? since 2005 is listening on tcp 1900.

Im doing a reinstall of SQl2000 to see if that fixes it.

--
Thanks
Morris


"Rick Byham, (MSFT)" wrote:

On Thursday, July 19, 2007 11:51 PM
peter wrote:

Hello Morris,It seems some protocol related registry keys might be corrupted
Hello Morris,

It seems some protocol related registry keys might be corrupted or missing.
I agree reinstall SQL 2000 instance might be helpful. Also, I notice that
you only have RTM installed, it's suggested that you upgrade to SQL 2000
SP4 to see if the issue still occurs.

http://www.microsoft.com/downloads/details.aspx?familyid=8e2dfc8d-c20e-4446-
99a9-b7f0213f8bc5

Best Regards,

Peter Yang
MCSE2000/2003, MCSA, MCDBA
Microsoft Online Partner Support

When responding to posts, please "Reply to Group" via your newsreader so
that others may learn and benefit from your issue.

=====================================================

This posting is provided "AS IS" with no warranties, and confers no rights.

On Monday, July 23, 2007 11:49 PM
peter wrote:

Hi Morris,Any update on this issue?
Hi Morris,

Best Regards,

=====================================================

On Wednesday, January 16, 2008 5:24 AM
sachin lad wrote:


Submitted via EggHeadCafe - Software Developer Portal of Choice
WPF Datagrid as ComboBox Dropdown Part 2
http://www.eggheadcafe.com/tutorials/aspnet/5af72df7-5b0b-4ac2-be96-e24127040bbf/wpf-datagrid-as-combobox.aspx

0 new messages