Sqlcmd: Error: Microsoft SQL Server Native Client 10.0 : Communication link failure

Sqlcmd: Error: Microsoft SQL Server Native Client 10.0 : Communication link failure

下面,您会注意到一些 Windows 命令提示符命令,我正尝试从 Microsoft SQL Server 2008

的 64 位 Program Files 文件夹中调用这些命令
C:\Program Files\Microsoft SQL Server0\Tools\Binn>SQLCMD -S "SQLI2B2" -d
 "I2B2_CRC-DEV" -i "C:\SVN\ONT\SQL SERVER\DX_SQLSERVER.sql" -E

HResult 0x2746, Level 16, State 1 TCP Provider: An existing connection was forcibly closed by the remote host.

Sqlcmd: Error: Microsoft SQL Server Native Client 10.0 : Communication link failure.

c:\Program Files\Microsoft SQL Server0\Tools\Binn>

现在,我要连接的数据库(服务器)是 SQL Server 2008。我在 "Microsoft SQL Server" 文件夹下有几个目录。 90、100、110 和 120。只有 100 和 110 有 .\Tools\Binn\SQLCMD.EXE 文件。我在 \Control Panel\All Control Panel Items\Administrative Tools\Data Sources (ODBC)\Drivers\ 中注意到以下驱动程序,所以我不知道客户端驱动程序是否适合我的服务器版本。

Name                            Version
SQL Server                      6.01.7601.17514
SQL Server Native Client 10.0   2009.100.1600.01
SQL Server Native Client 11.0   2011.110.3000.00

命令中的 -E 意味着使用 Windows 身份验证,而不是 SQL 服务器身份验证(使用实际用户和密码)。

什么可能导致此错误,如何解决?

备注:

这是在 Windows 7 上找到的。以下解决方案仅适用于早期操作系统。

https://msdn.microsoft.com/en-us/library/ms187005.aspx

第一个错误:

TCP Provider: An existing connection was forcibly closed by the remote host.

Communication link failure

较小的文件会 运行,但如果文件太大,您仍然会收到此异常。我能找到的唯一解决方案是将包含 T-SQL 命令的文件分成多个较小的文件。

第二个错误:

Sqlcmd: Error: Microsoft SQL Server Native Client 10.0 : Communication link failure.

除了可执行文件本身之外,"Binn" 文件夹中肯定还有 SQLCMD.EXE 需要 运行 的其他文件。附加到现有的 SYSTEM "PATH" 环境变量或在 \Control Panel\All Control Panel Items\System\Advanced system settings\Environment Variables\.

中添加新的 USER "PATH" 环境变量
Variable name: PATH
Variable value: C:\Program Files\Microsoft SQL Server0\Tools\Binn\