snippetsqlMinor
How do I use `sys.dm_exec_connections` in combination with SUSER_SNAME()?
Viewed 0 times
combinationdm_exec_connectionssuser_snamewithsyshowuse
Problem
How do I use
I want to see the username corresponding to each record in sys.dm_exec_connections.
sys.dm_exec_connections in combination with SUSER_SNAME()?I want to see the username corresponding to each record in sys.dm_exec_connections.
Solution
As others have already pointed out the info you want is in
sys.dm_exec_sessions. However if you want to pull from both DMVs this would work:SELECT c.connect_time
, s.login_time
, s.host_name
, s.login_name
FROM sys.dm_exec_connections AS c
JOIN sys.dm_exec_sessions AS s ON c.session_id = s.session_idCode Snippets
SELECT c.connect_time
, s.login_time
, s.host_name
, s.login_name
FROM sys.dm_exec_connections AS c
JOIN sys.dm_exec_sessions AS s ON c.session_id = s.session_idContext
StackExchange Database Administrators Q#13124, answer score: 7
Revisions (0)
No revisions yet.