SQLServerCentral Article

The Dedicated Administrator Connection

,

Introduction

SQL Server 2005 introduced a dedicated administrator connection (DAC) allowing administrators to access a remote or local SQL Server instance, even when the server is not responding. Using the SQLCMD command line tool, a member of the sysadmin role can connect to the server and perform diagnostic functions, or execute TSQL statements to resolve a problem.

The special administrator switch (-A) is used with the SQLCMD tool, or by prefixing admin to the instance name (sqlcmd -Sadmin:instance). The DAC is also available through Management Studio by connecting to admin:instance.

There are certain restrictions on the connection:

  1. Only one DAC is allowed at a time;
  2. The DAC will attempt to connect to the default database, which will generate an error if the database is unavailable. Executing sqlcmd -A -d master will force a connection to the master database, which will always be available;
  3. You cannot run parallel queries or commands, like RESTORE or BACKUP;
  4. Limited resources are available to the DAC, so avoid running queries that could push an already suffering SQL instance over the edge;
  5. DAC is not available in the Express Edition without a trace flag;
  6. By default only local connections are allowed, unless sp_configure is executed with the remote admin connections option;

Books Online (BOL) topic 'Using a Dedicated Administrator Connection', discusses the commands recommended for use through DAC. These typically include querying system tables to look for blocks and suspect processes, and DBCC commands to free resources and check the health of databases. Ye Old Faithful command KILL is also available through DAC. These commands are too lengthy to list in this article.

Examples

Open a DOS Command Prompt, start your SQL instance and SQL Browser service, and execute the following command in the Command Prompt window:

sqlcmd -S yourservername -U sa -P yourpassword -A

You will be presented with a prompt: 1>.

Enter the command below (all commands should be followed by GO) to show all processes running on the server:

select Session_id, login_time, cpu_time, memory_usage, reads, writes, login_name from sys.dm_exec_sessions WITH (NOLOCK)
GO

The results don't display very well in a DOS window. Enter QUIT to get out of sqlcmd, and let's try this again from Management Studio.

Open Management studio, and open a new Query connection to admin:instance using a sa account. You cannot use the Object Explorer with DAC.

Execute the command again in the new query window.

select Session_id, login_time, cpu_time, memory_usage, reads, writes, login_name from sys.dm_exec_sessions WITH (NOLOCK)

You will see the same results from the sqlcmd session, but these will be neatly formatted.

Conclusion

A fair amount of DBA experience is required to effectively diagnose and resolve critical problems on a SQL server instance. In previous versions of SQL Server it was often not possible to diagnose a SQL Server instance which was no longer accepting connections. With DAC an administrator has a guaranteed connection to the SQL Server, and is able to resolve problems without the need for a reboot, or restarting the SQL server instance.

References

Books Online - Using a Dedicated Administrator Connection (http://msdn2.microsoft.com/en-us/library/ms189595.aspx)

Rate

4 (4)

You rated this post out of 5. Change rating

Share

Share

Rate

4 (4)

You rated this post out of 5. Change rating