今天进行负载均衡的测试的时候 想查询一下数据库相关信息 百度了下 找到解决方案为: SELECT SERVERNAME = CONVERT(NVARCHAR(),SERVERPROPERTY('SERVERNAME')) ,LOCAL_NET_ADDRESS AS 'IPAddressOfSQLServer' ,CLIENT_NET_ADDRESS AS 'ClientIPAddress' FROM SYS.DM_EXEC_CONNECTIONS WHERE SESSION_ID = @@SPI