I have a busy SQL 2012 server where connections to one particular database (using the same SQL login) don't show a "hostname", and I need to find out which box (of several) these connections are coming from.
I've tried all the normal built-in and 3rd-party tools (master.sys.processes
, sys.dm_exec_sessions
, sp_who2
, sp_WhoIsActive
, the SSMS Activity Monitor, even SQL Profiler and Idera Diagnostic Manager), none of them can give me the hostname of the server/client behind these connections, presumably because they all use the same underlying system tables/views.
I'd be fine with an IP address, too, but don't see any way to determine that from within SQL either.
In case this is any help:
sys.dm_exec_sessions
shows theclient_interface_name
is ODBC- Nothing captured for
program_name
either - The user is a SQL account that happens to be a SYSADMIN (yes, I know…)
I found a related question here (albeit from the other side), but that went unanswered.
At this point I'm tempted to disable the user so I can capture some failed logins in the SQL errorlog, but I don't imagine the application team will be happy with that.
Best Answer
Looks like I was just asking the question wrong, I found the answer under: How to get the client IP address from SQL Server 2008 itself?:
As Aaron mentioned in the comments, I had to use
sys.dm_exec_connections
to get the source IP. Here is the final version of the query I used: