0% found this document useful (0 votes)
53 views

DAC (Dedicated Admin Connection) SQL Server

DAC (Dedicated Admin Connection) SQL Server

Uploaded by

Rofiq Ahmed
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
53 views

DAC (Dedicated Admin Connection) SQL Server

DAC (Dedicated Admin Connection) SQL Server

Uploaded by

Rofiq Ahmed
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 3

https://www.sqldbachamps.

com
Praveen Madupu - +91 98661 30093
Sr SQL Server DBA, Dubai
[email protected]

DAC (Dedicated Administrator Connection) in SQL Server is a special diagnostic connection that allows
database administrators to access a running SQL Server instance to troubleshoot issues, especially when the
server is unresponsive to standard connections. This feature provides a backdoor for administrative tasks when
all other connections are not working due to resource overload, high CPU usage, memory issues, or
misconfigurations.

Key Points About DAC

● Availability: The DAC is available in all editions of SQL Server.


● One Connection: SQL Server allows only one DAC connection at a time, and this connection is only
available to members of the sysadmin fixed server role.
● Network vs. Local Access: By default, the DAC connection is available only from the local server using
the loopback IP address (127.0.0.1) or through SQLCMD. In SQL Server 2005 and later, it can be
enabled for remote connections (though this is usually done with caution).

When to Use the DAC

The DAC should be used for emergency troubleshooting scenarios like:

● SQL Server is unresponsive to standard queries.

https://www.sqldbachamps.com



The server has resource exhaustion (memory, CPU).
Deadlocks are causing issues.
Diagnosing configuration or performance problems.

How to Enable and Use DAC

1. Enabling Remote DAC Connections

By default, DAC is available only on the local machine, but you can enable remote DAC connections by following
these steps:

● Open SQL Server Management Studio (SSMS).


● Right-click on the server in Object Explorer and select Properties.
● In the Connections tab, check the box for "Allow remote connections to this server."
● Check the box for "Allow remote connections to DAC."

Alternatively, run the following T-SQL command:

sp_configure 'remote admin connections', 1;

RECONFIGURE;
https://www.sqldbachamps.com
Praveen Madupu - +91 98661 30093
Sr SQL Server DBA, Dubai
[email protected]
2. Connecting via DAC

● Using SQLCMD: The easiest way to use DAC is via SQLCMD, a command-line utility, using the -A
option:

SQLCMD -S servername -A

Replace servername with the name of your SQL Server instance.

Using SSMS: You can also use SQL Server Management Studio by connecting to the database instance, but
using the ADMIN: prefix before the server name. For example:

ADMIN:localhost

● Here, localhost refers to the local instance.


● Using .NET: You can also create a DAC connection programmatically using .NET code by specifying the
ApplicationIntent parameter as DAC in your connection string.

3. T-SQL Access and Commands

Once connected via DAC, you can run lightweight diagnostic queries such as:

https://www.sqldbachamps.com
● Check currently running queries:

SELECT * FROM sys.dm_exec_requests;

Check current sessions:

SELECT * FROM sys.dm_exec_sessions;

Review system resource status:

EXEC sp_who2;

You can also execute other queries or procedures to kill problematic processes, free up resources, or review log
files.

Limitations of DAC

● Resource Intensive Queries: DAC is primarily for diagnostic purposes, and its use should be limited to
lightweight queries. Running resource-heavy queries can worsen the server's state.
● Single Connection: Since DAC allows only one connection at a time, it’s possible for another user to
block the use of DAC unintentionally.
● Restricted Features: Some features, such as parallel queries or operations, may not work as expected
when using DAC.
https://www.sqldbachamps.com
Praveen Madupu - +91 98661 30093
Sr SQL Server DBA, Dubai
[email protected]
Example Scenario for DAC Use

1. Scenario: Your SQL Server instance becomes unresponsive due to a resource bottleneck, and the usual
connections (via SSMS or other clients) time out.
2. Steps to Solve:
○ Use SQLCMD to connect to the server via DAC using the -A flag.
○ Run a diagnostic query like sp_who2 to identify the blocking or runaway processes.
○Kill the problematic session or process using the KILL <session_id> command.
○Check server logs or use DMVs (Dynamic Management Views) to further investigate the
underlying issue.
3. Post-DAC Usage: After resolving the issue, make sure to exit the DAC connection, as it’s meant only for
emergency use.

Summary

The DAC connection in SQL Server is an invaluable tool for administrators to troubleshoot critical server issues
when standard connections are failing. It's available locally by default, can be enabled for remote use, and
supports running lightweight diagnostic commands.

https://www.sqldbachamps.com

You might also like