You may already be aware that I am a big advocate of the SQL Server Dynamic Management Views (DMV’s) and the benifits that they bring to the Database Administrator. They certainly came in handy with a requirement I had recently whereby I needed to identify the IP Address of a specific SQL Server Login and so I would like to share my solution with you.
The query below identifies all currently active SQL Server user connections by their SQL Server Login name. It provides details of the IP address that the connection is sourced from, along with the number of sessions and connections that the SQL Server Login is currently responsible for.
SELECT
B.login_name,
A.client_net_address,
NoOfConnections = COUNT(*)
FROM
sys.dm_exec_connections A
INNER JOIN sys.dm_exec_sessions B ON
A.session_id = B.session_id
GROUP BY
login_name,
client_net_address
This is achieved by using two of SQL Server DMV’s:


Pingback: SQL Snippet: SQL Server Wait Type Query | John Sansom - SQL Server DBA in the UK
Pingback: SQL Snippet: What SQL Server Agent Jobs were running at that time? | John Sansom - SQL Server DBA in the UK
Pingback: How to identify the most costly SQL Server queries using DMV's | John Sansom - SQL Server DBA in the UK
Pingback: SQL Snippet: Who owns that SQL Server Job? | John Sansom - SQL Server DBA in the UK
Pingback: How much memory is each SQL Server database using? | John Sansom - SQL Server DBA in the UK
Pingback: How to identify the most costly SQL Server queries using DMV's