Can connect through SSMS but not SQLCMD

  • We have two SQL 2016 servers (13.0.5026.0, Windows Server 2016), we'll call them "Server1" and "Server2". They should be exactly the same yet this is what happens:

    Server1:
    -can connect through SSMS, no problem
    -can connect using SQLCMD, no problem

    Server2:
    -can connect through SSMS, no problem
    -trying to connect through SQLCMD gives this error:

        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 : Client unable to establish connection.

    Another thing I tried was to create an ODBC data source to both servers and this is what I found:
    Server1:
    SQL Native Client 10.0 - Works
    SQL Native Client 11.0 - Works

    Server2:
    SQL Native Client 10.0 - Fails
    SQL Native Client 11.0 - Works

    So there seems to be an issue with SQL Server Native Client 10.0 on Server2. Does anyone have any ideas how to fix this or how to investigate it further?

  • auaiomrn - Friday, September 21, 2018 2:32 PM

    We have two SQL 2016 servers (13.0.5026.0, Windows Server 2016), we'll call them "Server1" and "Server2". They should be exactly the same yet this is what happens:

    Server1:
    -can connect through SSMS, no problem
    -can connect using SQLCMD, no problem

    Server2:
    -can connect through SSMS, no problem
    -trying to connect through SQLCMD gives this error:

        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 : Client unable to establish connection.

    Another thing I tried was to create an ODBC data source to both servers and this is what I found:
    Server1:
    SQL Native Client 10.0 - Works
    SQL Native Client 11.0 - Works

    Server2:
    SQL Native Client 10.0 - Fails
    SQL Native Client 11.0 - Works

    So there seems to be an issue with SQL Server Native Client 10.0 on Server2. Does anyone have any ideas how to fix this or how to investigate it further?

    What are your connection parameters?
    😎

  • Eirikur Eiriksson - Saturday, September 22, 2018 6:04 AM

    What are your connection parameters?
    😎

    Just the server name (-S) and query to run (-i). I tried with SQL authentication but it didn't change things. 

    The problem definitely seems to be with SQL Native Client 10.0 because when I connect to Server2 through SQLCMD from a server that has only SQL Native Client 11.0 (no 10.0), it is successful.

    A question would be, how can I force SQLCMD to use SQL Native Client 11.0 instead of 10.0 when both are available?
    Also, what could be different about Server2 that would prevent SQL Native Client 10.0 from connecting successfully?

Viewing 3 posts - 1 through 2 (of 2 total)

You must be logged in to reply to this topic. Login to reply