views:

131

answers:

2

Hi,

I have a script that connects to SQL Server 2005 named instance using osql. But the script throws the following errors:

[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 connection part of the script is shown below:

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

My question is : What is causing this error and what is the possible resolution?

+1  A: 

The -S parameter specifies the instance. Your example shows '\'. You'll need to change it to something like:

osql -E -S localhost\myInstance -i D:\scripts\script1.sql -o D:\scripts\script1.txt

http://msdn.microsoft.com/en-us/library/aa214012(SQL.80).aspx

You may also need to verify that your client and server configurations agree on the transport (shared memory, named pipes, TCP/IP), etc...

steamer25
Please see the edited version. It looks like I forgot to click the code icon to make the code looks as it should.
titanium
I've already found the possible cause. I looked at the SQL Server Configuration Manager. The named instance service has been stopped. Maybe somebody in our team stopped this on purpose though it didn't passed through proper ticket or just any notice via email.
titanium
A: 

Make sure that you're SQL Server allows remote connections and that you have TCP/IP and named pipes connections enabled.

Joseph
I've already checked TCP/IP and named pipes, they are both enabled. Remote connections is also enabled.
titanium