SQLCMD :CONNECT Script Unable to Connect

  • I have the following script:

    --Updated connection string

    :CONNECT sql.mc.com -U [AdminAccount] -P [Password]

    SELECT * FROM SYS.databases

    GO

    When I run three lines I receive the following error:

    Connecting to sql.mc.com as sa...

    Fatal scripting error. Cannot open connection specified in the SQLCMD script.

    A network-related or instance-specific error occurred while establishing a connection to SQL Server. The server was not found or was not accessible. Verify that the instance name is correct and that SQL Server is configured to allow remote connections. (provider: Named Pipes Provider, error: 40 - Could not open a connection to SQL Server)

    I have verified that my server address is correct as well as the login I am using. I am able to connect to sql.mc.com using SSMS with the credentials above. I also enabled SQLCMD by going to Query –> SQLCMD to enable SQLCMD in the query editor.

    Any idea why I may be having this issue?

  • No idea what the problem is but... I wouldn't use the SA login ever (most folks in-the-know will disable it on their servers) and I sure wouldn't embed the password for it in any script anywhere. My recommendation would be to use Windows Authentication even for experiments.

    --Jeff Moden


    RBAR is pronounced "ree-bar" and is a "Modenism" for Row-By-Agonizing-Row.
    First step towards the paradigm shift of writing Set Based code:
    ________Stop thinking about what you want to do to a ROW... think, instead, of what you want to do to a COLUMN.

    Change is inevitable... Change for the better is not.


    Helpful Links:
    How to post code problems
    How to Post Performance Problems
    Create a Tally Function (fnTally)

  • Yeah, not smart. I am now using another login that has system and server roles.

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

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