Blog Post

SQL Server - Dedicated Administrator Connection (DAC)

,

This a short post looking at the Dedicated Administrator Connection or DAC for short. In extreme circumstances, when there is a complete lack of resources available, for example, it is possible for SQL Server to enter a state whereby no further connections can be made to the instance. In versions prior to SQL server 2005 this meant the DBA might not be able to connect to the said instance to begin troubleshooting, kill rouge processes causing the issue, or diagnose the cause of the problem. A special connection called a Dedicated Administrator Connection (DAC) was introduced in SQL Server 2005 that was designed to be accessible even when no other connections are available.

DAC access must be specifically requested. You connect via the command line tool SQLCMD using the -A or /A flag. This is generally the recommended way as it uses fewer resources than connecting through management studio but you can use both and we will look at connecting via the GUI first.

Connecting to the DAC using the GUI

If you try and connect to DAC using the object explorer in management studio you will get an error similar to:

Cannot connect to admin:SQLSERVER2008R2.

This is because you can't connect to the DAC in object explorer. You can however connect to it from a query window from management studio click <file> <New Database Engine Query>

You then connect using the DAC by specifying ADMIN: in front of the instance name:

DAC

Click on connect and you should get in. You can the run TSQL statements such as SP_WHO query DMV's and KILL any rouge processes in your efforts to troubleshoot and fix the problem

Connecting to DAC using SQLCMD

To connect to the DAC using the SQLCMD console:

Open a command prompt and connect to the instance using the necessary flag

SQLCMD -E -SSQLSERVER2008R2 -A

from the SQLCMD prompt you can then run things like sp_who query DMVs and kill sessions and troubleshoot as needed.

There can only be on connection on the DAC at anyone time if two people try and connect the last person to try and connect will get an error similar to:

A connection was successfully established with the server, but then an error occurred during the login process. (provider: TCP Provider, error: 0 - The specified network name is no longer available.) (Microsoft SQL Server, Error: 64)

which I think you will agree is pretty non-specific but there will be a more meaningful message in the SQL Server log:

Could not connect because the maximum number of '1' dedicated administrator connections already exists. Before a new connection can be made, the existing dedicated administrator connection must be dropped, either by logging off or ending the process.

Error: 17810, Severity: 20, State: 2

My GUI session was still connected using the DAC. For this reason I would recommend only connecting via the DAC as needed and disconnecting from it as soon as your done.

Some other points to note:

The DAC is only available locally by default but this can be reconfigured to allow remote connections using the configuration option called 'Remote Admin Connections'

To login using the DAC you must be a member of the sysadmin server role.


Rate

You rated this post out of 5. Change rating

Share

Share

Rate

You rated this post out of 5. Change rating