Created
April 2, 2021 15:11
-
-
Save bh3605/630cb9f9e2bbd39cbbf4519fc0aa8df2 to your computer and use it in GitHub Desktop.
Returns a sql db server's signed in users
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
SELECT SESSION.login_name AS 'Database User Name' | |
,MAX(SESSION.login_time) AS 'Login Time' | |
,SESSION.host_name AS 'PC Name' | |
,SESSION.program_name AS 'Program Using' | |
,SESSION.client_interface_name AS 'Interface' | |
,UM.USER_NAME AS 'User' | |
FROM master.sys.dm_exec_Sessions SESSION | |
WHERE SESSION.session_id >= 51 -- All user Sessions | |
GROUP BY SESSION.login_name | |
,SESSION.host_name | |
,SESSION.program_name | |
,SESSION.client_interface_name | |
,UM.USER_NAME |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment