[转帖]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.

SQLCopy

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)

原文地址:https://www.cnblogs.com/jinanxiaolaohu/p/11451592.html

时间: 2024-10-12 14:58:21

[转帖]sys.dm_exec_connections (Transact-SQL)的相关文章

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-microsoft-sql-server-error-208.aspx ---------- When you use Microsoft SQL Server Management Studio 2008 to access SQL Azure, if you get the following error

Transact—SQL

T-SQL是Microsoft公司在关系型数据库管理系统SQL Server中的SQL-3标准的实现,是微软对SQL的扩展,具有SQL的主要特点,同时增加了变量.运算符.函数.流程控制和注释等语言元素,使得其功能更加强大.T-SQL对SQL Server 十分重要,SQL Server中使用图形界面能够完成的所有功能,都可以利用T-SQL来实现.使用T-SQL操作时,与SQL Server通信的所有应用程序都通过向服务器发送T-SQL语句来进行,而与应用程序的界面无关. 根据其完成的具体功能,可

[转帖]关于Java中SQL语句的拼接规则

自学demo 的时候遇到的问题 结果应该是 '"+e.getName()+"' 注意 一共有三组标点符号 (除去 方法函数后面的括号) 实现目标语句是这个注意,这里的java变量是idd int idd; String sql = "SELECT id, piUrl FROM picinfos WHERE id BETWEEN '" + idd + "' AND 10" ; java中的字符串只能双引号,如果字符串中需要拼接变量,该变量用单引号括

SQL Server 2016里的sys.dm_exec_input_buffer

在你的DBA职业里,你们谁有用过DBCC INPUTBUFFER命令,来获得已经提交到SQL Server特定会话的最后SQL语句?请举手!大家都用过! 我们都知道DBCC命令有点尴尬,因为你不能在T-SQL查询里调用它们,你也不能关联它们的输出到其它DMV/DMF.例如你想为每个用户会话返回最后一个执行的SQL语句.... sys.dm_exec_input_buffer 在SQL Server 2016里,事情就变得简单多,因为微软为你提供了一个新DMFsys.dm_exec_input_b

SQL Server CPU

解决数据库系统的性能问题可能是一项艰巨的任务.了解如何找到问题很重要,但是了解系统对特定请求作出特定反应的原因更加重要.影响数据库服务器上的 CPU 利用率 的因素有很多:SQL 语句的编译和重新编译.缺少索引.多线程操作.磁盘瓶颈.内存瓶颈.日常维护以及抽取.转换和装载 (ETL) 活动和其他因素.利用 CPU 本身并不是一件坏事情,执行任务是 CPU 的职责所在.CPU 利用率正常的关键是确保 CPU 处理您需要它处理的任务,而不是将循环浪费在不良优化的代码或缓慢的硬件上. 达到同一目的的两

从wait_type入手模拟SQL Server Lock

一.LCK_M_S,等待获取共享锁 开始一SQL TRAN,其中执行对某数据的UPDATE.但并不COMMIT,也不ROLLBACK. begin tran update [dbo].[HR_Employee] set [Description]='ZZ' 这样,便使用排它锁锁定了该[Employee]表. 在另一会话中,执行对该表的SELECT操作.至此,死锁产生. select * from [dbo].[HR_Employee] 使用下列script查询当前锁情况. 1 SELECT wt

SQL Server 中WITH (NOLOCK)浅析

原文:SQL Server 中WITH (NOLOCK)浅析 概念介绍 开发人员喜欢在SQL脚本中使用WITH(NOLOCK), WITH(NOLOCK)其实是表提示(table_hint)中的一种.它等同于 READUNCOMMITTED . 具体的功能作用如下所示(摘自MSDN): 1: 指定允许脏读.不发布共享锁来阻止其他事务修改当前事务读取的数据,其他事务设置的排他锁不会阻碍当前事务读取锁定数据.允许脏读可能产生较多的并发操作,但其代价是读取以后会被其他事务回滚的数据修改.这可能会使您的

SQL 常用语句

–-表现最差的前10名使用查询 SELECT TOP 10 ProcedureName = t.text, ExecutionCount = s.execution_count, AvgExecutionTime = isnull ( s.total_elapsed_time / s.execution_count, 0 ), AvgWorkerTime = s.total_worker_time / s.execution_count, TotalWorkerTime = s.total_wo

疑难杂症--SQL SERVER 2012下数据库内存异常回收

--=================================================================== --背景: 在一台SQL SERVER 2012 SP1(11.0.3000)服务器上,由于批处理请求较高,CPU使用率超过40%,于是开始各种调研.. 服务器情况: 服务器物理内存为128GB, 分配给SQL SERVER 115GB,Windows 可用物理内存为6GB左右 压力情况: 批处理请求超过30000+,有大量UPDATE和INSERT操作,C