在SQL Server中获取当前连接属性 [英] Getting current connection properties in SQL Server

查看:159
本文介绍了在SQL Server中获取当前连接属性的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

在MS SQL Server中,数据库属性对话框左侧的查看连接属性链接。单击这会带来连接属性对话框与当前连接的属性,如身份验证方法,网络协议,计算机名称等...

In MS SQL Server, the Database Properties dialog has the "View Connection Properties" link over on the left. Clicking that brings the "Connection Properties" dialog with properties of the current connection, such as Authentication Method, Network Protocol, Computer Name, etc...

通过运行sql查询以编程方式获取该信息?该查询是什么样子?

Is there a way to get that information programmatically by running a sql query? What would that query look like?

推荐答案

SQL 2005并且在您询问 sys.dm_exec_connections 。要检索您当前的连接属性,您可以运行:

SQL 2005 and after you interrogate sys.dm_exec_connections. To retrieve your current connection properties you'd run:

select * from sys.dm_exec_connections
where session_id = @@SPID

字段值取决于用于连接的协议(共享内存,命名管道或tcp),但都包含有关所使用的身份验证方法,协议和客户端网址的信息。

The field values depend on the protocol used to connect (shared memory, named pipes or tcp) but all contain information about authentication method used, protocol and client net address.

这篇关于在SQL Server中获取当前连接属性的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆