none
Can't Start SQLCMD odbc error RRS feed

  • Question

  • I tried run SQLCMD from the command line:

    sqlcmd -E -S MSSQLSERVER

    Sqlcmd: Error: Microsoft ODBC Driver 11 for SQL Server : Named Pipes Provider: 
        Could not open a connection to SQL Server [67]. .
    Sqlcmd: Error: Microsoft ODBC Driver 11 for SQL Server : Login timeout expired.
    Sqlcmd: Error: Microsoft ODBC Driver 11 for SQL Server :
        A network-related or instance-specific error has occurred 
        while establishing a connection to SQL Server. Server is not found or not accessible. 
    Check if instance name is correct and if SQL Server is configured to allow remote connections.
    For more information see SQL Server Books Online..

    Thursday, January 7, 2016 11:55 AM

Answers

  • Hello,

    Is SQL Server running local on the machine? The replace MSSQLSERVER with a dot (if it's a Default instance)

    sqlcmd -E -S .

    Optional you can use the Parameter -L (large L) to list local instances

    sqlcmd -L


    Olaf Helper

    [ Blog] [ Xing] [ MVP]

    • Proposed as answer by Ice Fan Friday, January 8, 2016 10:48 AM
    • Marked as answer by Morgan2015 Tuesday, January 12, 2016 6:27 PM
    Thursday, January 7, 2016 12:07 PM
    Moderator

  • If you connecting remote server then

    server property -->connection -->remote connection-> should enabled Allow remote connection.

    syntax:-

    sqlcmd -S Servername -U username -P password


    Please click Mark As Answer if my post helped.


    • Edited by Times Decides Friday, January 8, 2016 4:28 AM
    • Marked as answer by Morgan2015 Tuesday, January 12, 2016 6:27 PM
    Friday, January 8, 2016 4:26 AM

All replies

  • Hello,

    Is SQL Server running local on the machine? The replace MSSQLSERVER with a dot (if it's a Default instance)

    sqlcmd -E -S .

    Optional you can use the Parameter -L (large L) to list local instances

    sqlcmd -L


    Olaf Helper

    [ Blog] [ Xing] [ MVP]

    • Proposed as answer by Ice Fan Friday, January 8, 2016 10:48 AM
    • Marked as answer by Morgan2015 Tuesday, January 12, 2016 6:27 PM
    Thursday, January 7, 2016 12:07 PM
    Moderator

  • If you connecting remote server then

    server property -->connection -->remote connection-> should enabled Allow remote connection.

    syntax:-

    sqlcmd -S Servername -U username -P password


    Please click Mark As Answer if my post helped.


    • Edited by Times Decides Friday, January 8, 2016 4:28 AM
    • Marked as answer by Morgan2015 Tuesday, January 12, 2016 6:27 PM
    Friday, January 8, 2016 4:26 AM
  • Might be just my instance but I finally solved it by switching to a quoted instance reference;

    From: sqlcmd -E -S localhost

    To: sqlcmd -E -S "<servername\instance>"

    Or in Management Studio dynamically grabbing the current instance,

    DECLARE @Cmd VARCHAR(1024)

    SET @Cmd = 'sqlcmd -E -S "' + @@SERVERNAME + '"

    EXEC xp_cmdshell @Cmd

    Thursday, January 18, 2018 10:37 AM