SQL 获取数据IP,ServerName,ClientIPAddress

SELECT SERVERNAME = CONVERT(NVARCHAR(128),SERVERPROPERTY('SERVERNAME'))
,LOCAL_NET_ADDRESS AS 'IPAddressOfSQLServer'
,CLIENT_NET_ADDRESS AS 'ClientIPAddress'
FROM SYS.DM_EXEC_CONNECTIONS WHERE SESSION_ID = @@SPID

posted @ 2016-10-26 15:38  管学文  阅读(626)  评论(0编辑  收藏  举报