[转帖]sys.dm_exec_connections (Transact-SQL)
sys.dm_exec_connections (Transact-SQL)
https://docs.microsoft.com/en-us/sql/relational-databases/system-dynamic-management-views/sys-dm-exec-connections-transact-sql?view=sql-server-2017
APPLIES TO:
SQL Server
Azure SQL Database
Azure SQL Data Warehouse
Parallel Data Warehouse
Returns information about the connections established to this instance of SQL Server and the details of each connection. Returns server wide connection information for SQL Server. Returns current database connection information for SQL Database.
Note
To call this from Azure SQL Data Warehouse or Parallel Data Warehouse, use sys.dm_pdw_exec_connections (Transact-SQL).
| Column name | Data type | Description |
|---|---|---|
| session_id | int | Identifies the session associated with this connection. Is nullable. |
| 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. |
| connect_time | datetime | Timestamp when connection was established. Is not nullable. |
| net_transport | nvarchar(40) | Always returns Session when a connection has multiple active result sets (MARS) enabled.
Note: Describes the physical transport protocol that is used by this connection. Is not nullable. |
| protocol_type | nvarchar(40) | Specifies the protocol type of the payload. It currently distinguishes between TDS (TSQL) and SOAP. Is nullable. |
| protocol_version | int | Version of the data access protocol associated with this connection. Is nullable. |
| 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. |
| encrypt_option | nvarchar(40) | Boolean value to describe whether encryption is enabled for this connection. Is not nullable. |
| auth_scheme | nvarchar(40) | Specifies SQL Server/Windows Authentication scheme used with this connection. Is not nullable. |
| node_affinity | smallint | Identifies the memory node to which this connection has affinity. Is not nullable. |
| num_reads | int | Number of byte reads that have occurred over this connection. Is nullable. |
| num_writes | int | Number of byte writes that have occurred over this connection. Is nullable. |
| last_read | datetime | Timestamp when last read occurred over this connection. Is nullable. |
| last_write | datetime | Timestamp when last write occurred over this connection. Not Is nullable. |
| net_packet_size | int | Network packet size used for information and data transfer. Is nullable. |
| client_net_address | varchar(48) | Host address of the client connecting to this server. Is nullable.
Prior to V12 in Azure SQL Database, this column always returns NULL. |
| client_tcp_port | int | Port number on the client computer that is associated with this connection. Is nullable.
In Azure SQL Database, this column always returns NULL. |
| local_net_address | varchar(48) | Represents the IP address on the server that this connection targeted. Available only for connections using the TCP transport provider. Is nullable.
In Azure SQL Database, this column always returns NULL. |
| local_tcp_port | int | Represents the server TCP port that this connection targeted if it were a connection using the TCP transport. Is nullable.
In Azure SQL Database, this column always returns NULL. |
| connection_id | uniqueidentifier | Identifies each connection uniquely. Is not nullable. |
| parent_connection_id | uniqueidentifier | Identifies the primary connection that the MARS session is using. Is nullable. |
| 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. |
| pdw_node_id | int | Applies to: Azure SQL Data Warehouse, Parallel Data Warehouse
The identifier for the node that this distribution is on. |
Permissions
On SQL Server, requires VIEW SERVER STATE permission.
On SQL Database Premium Tiers, requires the VIEW DATABASE STATE permission in the database. On SQL Database Standard and Basic Tiers, requires the Server admin or an Azure Active Directory admin account.
Physical Joins

Relationship Cardinalities
| dm_exec_sessions.session_id | dm_exec_connections.session_id | One-to-one |
| dm_exec_requests.connection_id | dm_exec_connections.connection_id | Many to one |
| dm_broker_connections.connection_id | dm_exec_connections.connection_id | One to one |
Examples
Typical query to gather information about a queries own connection.
SELECT
c.session_id, c.net_transport, c.encrypt_option,
c.auth_scheme, s.host_name, s.program_name,
s.client_interface_name, s.login_name, s.nt_domain,
s.nt_user_name, s.original_login_name, c.connect_time,
s.login_time
FROM sys.dm_exec_connections AS c
JOIN sys.dm_exec_sessions AS s
ON c.session_id = s.session_id
WHERE c.session_id = @@SPID;
See Also
Execution Related Dynamic Management Views and Functions (Transact-SQL)
[转帖]sys.dm_exec_connections (Transact-SQL)的更多相关文章
- [转帖]Kerberos和NTLM - SQL Server
Kerberos和NTLM - SQL Server https://www.cnblogs.com/dreamer-fish/p/3458425.html 当我们使用Windows Authenti ...
- Invalid object name ‘sys.configurations’. (Microsoft SQL Server, Error: 208)
http://blogs.msdn.com/b/ramaprasanna/archive/2009/09/16/invalid-object-name-sys-configurations-micro ...
- 通过sys.objects查询SQL SERVER数据库改动内容
适用于: SQL Server 2008 + .Azure SQL 数据库.Azure SQL 数据仓库.并行数据仓库 系统视图sys.objects,在数据库中用户定义(创建)的每个架构范围对象(例 ...
- (非原)SQL注入专题--整理帖 && like 语句拼sql 如何防止注入攻击。
原地址:blog.csdn.net/lvjin110/article/details/28697695 like 语句拼sql 如何防止注入攻击?http://bbs.csdn.net/topics/ ...
- [转帖]关于Java中SQL语句的拼接规则
关于Java中SQL语句的拼接规则 自学demo 的时候遇到的问题 结果应该是 '"+e.getName()+"' 注意 一共有三组标点符号 (除去 方法函数后面的括号) 实现目标 ...
- [转帖] SQL参数化的优点 CopyFrom https://www.cnblogs.com/-lzb/articles/4840671.html
梦在远方的小猪 感谢原作者... 后面总结的五点感觉挺好的.. 自己之前的知识点一直没有串起来. 转帖记录一下感谢. sql参数化参数化 说来惭愧,工作差不多4年了,直到前些日子被DBA找上门让我优 ...
- SQL Server 2005 系统数据介绍:dm_exec_connections
原文:SQL Server 2005 系统数据介绍:dm_exec_connections 转载:http://msdn.microsoft.com/zh-cn/library/ms181509(SQ ...
- SQL SERVER中的sys.objects和sysobjects的区别
这三个视图都是存在于SQL Server的每个数据库中.在SQL Server 2000中,它们都是系统表,而不是视图. 关于两个版本中系统表和系统的视图的对应关系,参考:http://technet ...
- SQL SERVER 活动监视-sys.dm_exec_requests
sys.dm_exec_requests (Transact-SQL)应用: 针对 SQL Server 内正在执行的每个请求返回一行.sys.dm_exec_connections.sys.dm_e ...
随机推荐
- 使用std::function改善模板的低效性
泛型编程中,模板会根据传入类型的不同,生成多种实例,相对低效. 模板编程: #include <iostream> using namespace std; //未使用函数包装器 temp ...
- Public model for matrix
以下是可以加减乘除(就是乘逆矩阵啦)以及求若干次幂.行列式和逆的矩阵模板. 欢迎大家指正其中可能存在的错误(只验证了求逆的正确性). 顺便提一下这种复杂度低于定义式求逆的方法,来自于我的高等代数书,思 ...
- windows下注册表脚本编写
Reg文件就是我今天所说的注册表脚本文件,双击可将其中的数据写入注册表.利用注册表脚本文件可以对注册表进行关于键值的任何操作,而且还不受注册表被禁用的限制. 我们平常对注册表的修改大体上可以分 ...
- web软件测试基础系统测试简化理论
系统测试点主要如下 1.系统测试基础-2.测试对象与测试级别-3.系统测试类型-4.系统测试方法-5.系统测试之软件测试质量. 1.系统测试:是尽可能彻底地检查出程序中的错误,提高软件系统的可靠性. ...
- Python3.5以上Celery4.2.1启动报错:ImportError: cannot import name 'LRUCache' from 'kombu.utils.functional'
服务器:Centos7 Python版本:Python 3.7.0 Celery版本:4.2.1 Python3.5以上,OrderDict不允许在迭代过程中进行修改,导致LRUCache.updat ...
- Raspberry Pi 4B Web服务器配置
目录 1. 安装nginx 2. 安装PHP 3. 修改nginx配置文件 4. 安装MariaDB数据库 参考资料1:树莓派4B安装PHP7.3 + Nginx + MySQL 教程 参考资料2:[ ...
- 测试puppeteer模拟度检测
var puppeteer = require('puppeteer'); const devices = require('puppeteer/DeviceDescriptors'); const ...
- Leetcode题目322.零钱兑换(动态规划-中等)
题目描述: 给定不同面额的硬币 coins 和一个总金额 amount.编写一个函数来计算可以凑成总金额所需的最少的硬币个数.如果没有任何一种硬币组合能组成总金额,返回 -1. 示例 1: 输入: c ...
- 2018-2019-2 20165210《网络对抗技术》Exp9 Web安全基础
2018-2019-2 20165210<网络对抗技术>Exp9 Web安全基础 实验目的 本实践的目标理解常用网络攻击技术的基本原理. 实验内容 安装Webgoat SQL注入攻击 - ...
- 第11组 Beta冲刺(1/5)
第11组 Beta冲刺(1/5) 队名 不知道叫什么团队 组长博客 https://www.cnblogs.com/xxylac/p/11913626.html 作业博客 https://www. ...