Network timeout issue with sqlcmd from Linux

  • Hello experts,

    Some clients are testing a sqlcmd statement from a Linux host that is trying to run code in a SQL Server database on a Windows host. However, they are using the option -D (uppercase 'D'), which I do not see listed in the documentation for the Windows sqlcmd utility.

    Their goal is to use the sqlcmd with a data source reference instead of having to use the actual server name.

    Does anyone know why this would happen or how to fix it? I am guessing that somehow the data source name is not properly translating into the desired server name, but I am not sure and I also don't know how to correct it.

    The command is something like this:

    sqlcmd -D -S"My DSN" -Uwww_samp -PmyPwd  -Q"exec dbname.dbo.myproc"

    The error is:

    Login timeout expired.
    TCP Provider: Error code 0x2AF9.
    A network-related or instance specific error has occurred while establishing a connection to SQL Server. Server is not found or not accessible. ...

    Thanks for any help.

    -- webrunner

    • This topic was modified 4 years, 6 months ago by  webrunner.
    • This topic was modified 4 years, 6 months ago by  webrunner.
    • This topic was modified 4 years, 6 months ago by  webrunner.
    • This topic was modified 4 years, 6 months ago by  webrunner.

    -------------------
    A SQL query walks into a bar and sees two tables. He walks up to them and asks, "Can I join you?"
    Ref.: http://tkyte.blogspot.com/2009/02/sql-joke.html

  • the -D switch makes the name in the -S switch a DSN:

    https://docs.microsoft.com/en-us/sql/connect/odbc/linux-mac/connecting-with-sqlcmd?view=sql-server-ver15

    check to make sure the DSN specified is in one of the ini files on the client machine that article talks about.

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

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