查詢SQLServer的客戶端IP和主機名

ywxj_001發表於2020-12-16

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'


來自 “ ITPUB部落格 ” ,連結:http://blog.itpub.net/22996654/viewspace-2742716/,如需轉載,請註明出處,否則將追究法律責任。

相關文章