连接到SQL Server 2005命名实例时出现问题

时间:2020-12-26 10:20:33

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

我有一个脚本,使用osql连接到SQL Server 2005命名实例。但该脚本会引发以下错误:

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

我的问题是:导致此错误的原因是什么,可能的解决方案是什么?

2 个解决方案

#1


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

-S参数指定实例。您的示例显示'\'。您需要将其更改为:

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

您可能还需要验证您的客户端和服务器配置是否同意传输(共享内存,命名管道,TCP / IP)等...

#2


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

确保您的SQL Server允许远程连接,并且您已启用TCP / IP和命名管道连接。

#1


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

-S参数指定实例。您的示例显示'\'。您需要将其更改为:

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

您可能还需要验证您的客户端和服务器配置是否同意传输(共享内存,命名管道,TCP / IP)等...

#2


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

确保您的SQL Server允许远程连接,并且您已启用TCP / IP和命名管道连接。