问题
Below, you'll notice some Windows Command Prompt commands that I'm trying to call from the 64 bit Program Files folder for Microsoft SQL Server 2008
C:\Program Files\Microsoft SQL Server\100\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 Server\100\Tools\Binn>
Now, the database (server) I'm connecting to is SQL Server 2008. I had several directories under the "Microsoft SQL Server" folder. 90, 100, 110, and 120. Only 100 and 110 had the .\Tools\Binn\SQLCMD.EXE
file. I noticed the following drivers in \\Control Panel\All Control Panel Items\Administrative Tools\Data Sources (ODBC)\Drivers\
, so I don't know if the client driver is correct for my server version.
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
The -E
in the command implies to use Windows Authentication, instead of SQL Server Authentication (with an actual user and password).
What could be causing this error, and what can fix it?
Notes:
This was found on Windows 7. The following resolution only applies to earlier Operating Systems.
https://msdn.microsoft.com/en-us/library/ms187005.aspx
回答1:
First error:
TCP Provider: An existing connection was forcibly closed by the remote host.
Communication link failure
Smaller files will run, but if the file is too big, you'll still receive this exception. The only solution I could find was to break the file containing the T-SQL commands into multiple smaller files.
Second error:
Sqlcmd: Error: Microsoft SQL Server Native Client 10.0 : Communication link failure.
There must be other files in the "Binn" folder that SQLCMD.EXE needs to run besides the executable file itself. Either append to the existing SYSTEM "PATH" environment variable or add a new USER "PATH" environment variable in \\Control Panel\All Control Panel Items\System\Advanced system settings\Environment Variables\
.
Variable name: PATH
Variable value: C:\Program Files\Microsoft SQL Server\100\Tools\Binn\
来源:https://stackoverflow.com/questions/42846954/sqlcmd-error-microsoft-sql-server-native-client-10-0-communication-link-fail