Skip to main content

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.

Comments

  1. Great post Gethyn. The DAC is such a valuable feature and often one that gets overlooked, that is until it's needed :-). It has certainly saved my bacon on several occasions.

    As you point out, it's important to ensure that you enable the Remote DAC Connection, as the chances are that when the server has no resources available you won't be able to establish an RDP connection to make use of the local DAC.

    I like to ensure that enabling the Remote DAC is an item on my good old server configuration checklist for new server builds, that way it's enabled from day 1 if appropriate.

    ReplyDelete
  2. Hi John thanks for the comment, I'm pleased that you like the post. I agree that it is a good idea to enable the Remote DAC right upfront.

    ReplyDelete

Post a Comment

Popular posts from this blog

Always Encrypted

By David Postlethwaite

Always Encrypted is new features in SQL Server 2016 and it is also available in Azure SQL Database. Here you can encrypt columns in a table with a master key and a certificate so that they will appear as encrypted strings to those who don’t have the required certificate installed on their pc.
Once the certificate is installed on the computer then the unencrypted data can then be seen as normal.

The data passes from database to your application as the encrypted value, only the application with the correct certificate can unencrypt the data so it is secure across the wire. This will go some way to resolving the concern of people worried about putting their sensitive data on a shared server in the cloud such as Microsoft Azure and accessing the data across the Internet.

At the time of writing Always Encrypted is only supported with ADO.NET 4.6, JDBC 6.0 and ODBC 13.1 but expect other driver to become available.

The calling application (including SSMS) must also hav…

SQL Server 2012 and Virtual Service Accounts

This post is written by David Postlethwaite
If you are using SQL Server 2012 you will probably have noticed that the default account for the SQL services has changed from that used in previous versions. With SQL 2005 and 2008 the default account for SQL service and SQL Agent service was “NT Authority\System”. This is one the built in accounts on a Windows machine, managed by the machine and selectable from a dedicated dropdown list

The Network Service account was introduced in Windows 2003 as an alternative to using the LocalSystem account, which has full local system privileges on the local machine, a major security concern.
The Network Service has limited local privileges easing these security concerns but when many services on a machine use the Network Service account it becomes harder to track which service is actually accessing resources and performing actions, because all the services are using the one Network Service account.
Also, this account, by default, has sysadmin per…

SQL Server Express v SQL Server Developer Edition

SQL Server Express v  SQL Server Developer Edition
Over the weekend I received the following in an email from Ali Ahmad who asked me some questions about learning SQL Server. We exchanged a couple of emails so I have boiled this down to the most salient points.

Question:
Goal: I want to learn SQL Server inside out… for career progression as DBA/BI/data mining. I'm a data analyst and want to learn inside out about data warehousing.
•I understand relational database concepts...
•I have SQL Server 2014 express installed…
•I need to download the adventure works sample in order to play with it.
•So much knowledge on Microsoft website it's easy to get lost… where do I begin?

SQL Server Express v SQL Server Developer
This is interesting. If you want to learn SQL Server inside out including the Business Intelligence suite of applications I would suggest downloading the developer edition of SQL Server which since 2016 has been made available free of charge. Prior to that there was a f…