You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
title: "sys.dm_exec_connections (Transact-SQL) | Microsoft Docs"
2
+
description: "sys.dm_exec_connections (Transact-SQL) returns information about the connections established to this instance of the database engine and the details of each connection."
Returns information about the connections established to this instance of the database engine and the details of each connection. Returns server wide connection information for SQL Server and Azure SQL Managed Instance. Returns connection information for the current database in Azure SQL Database. Returns connection information for all databases in the same elastic pool for databases in [elastic pools](/azure/azure-sql/database/elastic-pool-overview) in Azure SQL Database.
30
29
@@ -36,10 +35,10 @@ Returns information about the connections established to this instance of the da
36
35
|session_id|**int**|Identifies the session associated with this connection. Is nullable.|
37
36
|most_recent_session_id|**int**|Represents the session ID for the most recent request associated with this connection. (SOAP connections can be reused by another session.) Is nullable.|
38
37
|connect_time|**datetime**|Timestamp when connection was established. Is not nullable.|
39
-
|net_transport|**nvarchar(40)**|Always returns **Session**when a connection has multiple active result sets (MARS) enabled.<br /><br /> **Note:** Describes the physical transport protocol that is used by this connection. Is not nullable.|
38
+
|net_transport|**nvarchar(40)**|When MARS is used, returns **Session**for each additional connection associated with a MARS logical session.<br /><br /> **Note:** Describes the physical transport protocol that is used by this connection. Is not nullable.|
40
39
|protocol_type|**nvarchar(40)**|Specifies the protocol type of the payload. It currently distinguishes between TDS ("TSQL"), "SOAP", and "Database Mirroring". Is nullable.|
41
40
|protocol_version|**int**|Version of the data access protocol associated with this connection. Is nullable.|
42
-
|endpoint_id|**int**|An identifier that describes what type of connection it is. This endpoint_id can be used to query the sys.endpoints view. Is nullable.|
41
+
|endpoint_id|**int**|An identifier that describes what type of connection it is. This `endpoint_id` can be used to query the `sys.endpoints` view. Is nullable.|
43
42
|encrypt_option|**nvarchar(40)**|Boolean value to describe whether encryption is enabled for this connection. Is not nullable.|
44
43
|auth_scheme|**nvarchar(40)**|Specifies [!INCLUDE[ssNoVersion](../../includes/ssnoversion-md.md)]/Windows Authentication scheme used with this connection. Is not nullable.|
45
44
|node_affinity|**smallint**|Identifies the memory node to which this connection has affinity. Is not nullable.|
@@ -54,26 +53,30 @@ Returns information about the connections established to this instance of the da
54
53
|local_tcp_port|**int**|Represents the server TCP port that this connection targeted if it were a connection using the TCP transport. Is nullable.<br /><br /> In [!INCLUDE[ssSDSfull](../../includes/sssdsfull-md.md)], this column always returns NULL.|
55
54
|connection_id|**uniqueidentifier**|Identifies each connection uniquely. Is not nullable.|
56
55
|parent_connection_id|**uniqueidentifier**|Identifies the primary connection that the MARS session is using. Is nullable.|
57
-
|most_recent_sql_handle|**varbinary(64)**|The SQL handle of the last request executed on this connection. The most_recent_sql_handle column is always in sync with the most_recent_session_id column. Is nullable.|
56
+
|most_recent_sql_handle|**varbinary(64)**|The SQL handle of the last request executed on this connection. The `most_recent_sql_handle` column is always in sync with the `most_recent_session_id` column. Is nullable.|
58
57
|pdw_node_id|**int**|**Applies to**: [!INCLUDE[ssSDWfull](../../includes/sssdwfull-md.md)], [!INCLUDE[ssPDW](../../includes/sspdw-md.md)]<br /><br /> The identifier for the node that this distribution is on.|
59
58
60
59
## Permissions
61
60
62
61
On [!INCLUDE[ssNoVersion_md](../../includes/ssnoversion-md.md)] and SQL Managed Instance, requires `VIEW SERVER STATE` permission.
63
62
64
63
On Azure SQL Database **Basic**, **S0**, and **S1** service objectives, and for databases in **elastic pools**, the [server admin](/azure/azure-sql/database/logins-create-manage#existing-logins-and-user-accounts-after-creating-a-new-database) account, the [Azure Active Directory admin](/azure/azure-sql/database/authentication-aad-overview#administrator-structure) account, or membership in the `##MS_ServerStateReader##`[server role](/azure/azure-sql/database/security-server-roles) is required. On all other SQL Database service objectives, either the `VIEW DATABASE STATE` permission on the database, or membership in the `##MS_ServerStateReader##` server role is required.
65
-
64
+
66
65
## Physical joins
67
-

66
+

Most commonly, for each row in `sys.dm_exec_connections` there is a single matching row in `sys.dm_exec_sessions`. However, in some cases such as system internal sessions or [Service Broker](../../database-engine/configure-windows/sql-server-service-broker.md) activation procedures, there may be a row in `sys.dm_exec_sessions` without a matching row in `sys.dm_exec_connections`.
77
+
78
+
When MARS is used, there may be multiple rows in `sys.dm_exec_connections` for a row in `sys.dm_exec_sessions`, one row for the parent connection, and one row for each MARS logical session. The latter rows can be identified by the value in the `net_transport` column being set to **Session**. For these connections, the value in the `connection_id` column of `sys.dm_exec_connections` matches the value in the `connection_id` column of `sys.dm_exec_requests` for MARS requests in progress.
79
+
77
80
## Examples
78
81
79
82
The following Transact-SQL query gathers information about a query's own connection.
@@ -98,4 +101,4 @@ Learn more about related concepts in the following articles:
98
101
-[Execution Related Dynamic Management Views and Functions (Transact-SQL)](../../relational-databases/system-dynamic-management-views/execution-related-dynamic-management-views-and-functions-transact-sql.md)
0 commit comments