Click here to monitor SSC
SQLServerCentral is supported by Red Gate Software Ltd.
 
Log in  ::  Register  ::  Not logged in
 
 
 

The Dedicated Administrator Connection

By Wayne Fillis,

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)

Total article views: 7317 | Views in the last 30 days: 4
 
Related Articles
FORUM

connectivity issues in SQL Server 2005 with sqlcmd

sqlcmd -E not working sqlcmd -E -S./SERVER is working

BLOG

:CONNECT in SSMS

Those people who are familiar with SQLCMD will recognize this command. It is used to connect to an ...

FORUM

sqlcmd -S

sqlcmd -S

ARTICLE

Introduction to SQLCMD

SQL Server 2005 has deprecated osql and isql as command line tools and replaced them with SQLCMD. Ha...

FORUM

Connecting to different instance of SQL Server

Connecting to different instance of SQL Server

Tags
 
Contribute

Join the most active online SQL Server Community

SQL knowledge, delivered daily, free:

Email address:  

You make SSC a better place

As a member of SQLServerCentral, you get free access to loads of fresh content: thousands of articles and SQL scripts, a library of free eBooks, a weekly database news roundup, a great Q & A platform… And it’s our huge, buzzing community of SQL Server Professionals that makes it such a success.

Join us!

Steve Jones
Editor, SQLServerCentral.com

Already a member? Jump in:

Email address:   Password:   Remember me: Forgotten your password?
Steve Jones