views:

628

answers:

1

I have a script that connects to SQL Server 2005 default instance. But I'm and being connected and instead got the following message

[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.

The script's content is:

osql -E -S <servername> -i D:\scripts\script1.sql -o D:\scripts\script1.txt

I looked at the network connection from SQL Server Configuration Manager. The TCP/IP is enabled but the Named Pipes is disabled.

My question is what could be the possible cause and solution for this error?

A: 

try osql -E -S(local) or osql -E -S. I have not figured out why sometimes it does work, and other times it does not.

JohnW