-
-
Save guneysus/40016f8570395981c7ca2ee4c2a45ad8 to your computer and use it in GitHub Desktop.
This file contains 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
USE master | |
go | |
SELECT sdes.database_id | |
,sdes.[host_name] | |
,sdes.[program_name] | |
,sdes.login_name | |
,sdes.login_time | |
,sdec.client_net_address | |
,sdec.local_net_address | |
,sdest.Query | |
FROM sys.dm_exec_sessions AS sdes | |
INNER JOIN sys.dm_exec_connections AS sdec ON sdec.session_id = sdes.session_id | |
CROSS APPLY ( | |
SELECT db_name(dbid) AS DatabaseName | |
,object_id(objectid) AS ObjName | |
,ISNULL(( | |
SELECT TEXT AS [processing-instruction(definition)] | |
FROM sys.dm_exec_sql_text(sdec.most_recent_sql_handle) | |
FOR XML PATH('') | |
,TYPE | |
), '') AS Query | |
FROM sys.dm_exec_sql_text(sdec.most_recent_sql_handle) | |
) sdest | |
where sdes.session_id <> @@SPID | |
ORDER BY sdec.session_id |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment