Several ways to check the IP address of the SQL Server you’re connected to.

1. Query the SQL server error log. This works on SQL Server 2012 and above, the search strings is enclosed in double quotes. For lower SQL server versions, try using single quotes

xp_readerrorlog 0, 1, "listening", "ipv4"

2. Using CONNECTIONPROPERTY

SELECT CONNECTIONPROPERTY('local_net_address') AS 'SQL Server IP Address'

3. Using DMVs, this returns the same data as (2)

SELECT local_net_address AS 'SQL Server IP Address' 
FROM sys.dm_exec_connections
WHERE session_id = @@SPID

Leave a Reply

Your email address will not be published. Required fields are marked *