Unable to connect using Dedicated Admin Connection through SQLCMD

  • I have created a batch file - test.bat - and inserted the following:

    sqlcmd -S srvr\instance -A

    I execute the bat file from the cmd prompt like this:

    sqlcmd -i "D:\test2.bat" -o "D:\test2.bat_out.txt"

    I get the following error:

    HResult 0x2, Level 16, State 1

    Named Pipes Provider: Could not open a connection to SQL Server [2].

    Sqlcmd: Error: Microsoft SQL Native Client : An error has occurred while establishing a connection to the server. When connecting to SQL Server 2005, this failure may be caused by the fact that under the default settings SQL Server does not allow remote connections..

    Sqlcmd: Error: Microsoft SQL Native Client : Login timeout expired.

    It's very odd. I can connect to that instance from SSMS with no problems!

    Anyone have an idea what's going on?

    __________________________________________________________________________________
    SQL Server 2016 Columnstore Index Enhancements - System Views for Disk-Based Tables[/url]
    Persisting SQL Server Index-Usage Statistics with MERGE[/url]
    Turbocharge Your Database Maintenance With Service Broker: Part 2[/url]

  • Do I have to RDP to the actual server for this to work?

    I just did that and it worked!

    Does that mean DAC only works once one is collected locally through RDP??

    __________________________________________________________________________________
    SQL Server 2016 Columnstore Index Enhancements - System Views for Disk-Based Tables[/url]
    Persisting SQL Server Index-Usage Statistics with MERGE[/url]
    Turbocharge Your Database Maintenance With Service Broker: Part 2[/url]

  • By default - DAC is only enabled on local connections. You can change that in the Surface Area Configuration Manager (enable remote DAC = True).

    From BOL:

    By default, the connection is only allowed from a client running on the server. Network connections are not permitted unless they are configured by using the SQL Server Surface Area Configuration tool or the sp_configure stored procedure with the remote admin connections option.

    Remember - DAC is essentially a connection that can't be denied, so tread lightly. Something malevolent grabs a hold of a DAC to your server, and you're essentially SOL, or rather reduced to pulling the network cord in order to fix.

    ----------------------------------------------------------------------------------
    Your lack of planning does not constitute an emergency on my part...unless you're my manager...or a director and above...or a really loud-spoken end-user..All right - what was my emergency again?

  • Matt is correct, this doesn't necessarily work from remote computers by default.

  • Thanks guys, cheers!

    __________________________________________________________________________________
    SQL Server 2016 Columnstore Index Enhancements - System Views for Disk-Based Tables[/url]
    Persisting SQL Server Index-Usage Statistics with MERGE[/url]
    Turbocharge Your Database Maintenance With Service Broker: Part 2[/url]

Viewing 5 posts - 1 through 4 (of 4 total)

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