查询SQLServer的客户端IP和主机名

SELECT  [服务器名称]= CONVERT(NVARCHAR(128),SERVERPROPERTY('a.SERVERNAME')) 

,a.LOCAL_NET_ADDRESS AS '服务器IP'

,a.CLIENT_NET_ADDRESS AS '客户端IP'

,b.host_name

 FROM SYS.DM_EXEC_CONNECTIONS a,sys.dm_exec_Sessions b WHERE a.SESSION_ID = b.session_id and b.host_name = 'ESB2-BJ' and a.session_id = 1660



 select client_net_address '客户端IP',local_net_address '服务器的IP' from sys.dm_exec_connections where Session_id=1971



 select * from sys.dm_exec_sessions where session_id=1630


 select * from sys.dm_exec_Sessions

 where host_name = 'ESB2-BJ'


请使用浏览器的分享功能分享到微信等