Skip to content

Instantly share code, notes, and snippets.

@aabundez
Created March 3, 2022 18:23
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save aabundez/b38ebff3ceb2ac5da378e8b9b15c7c4f to your computer and use it in GitHub Desktop.
Save aabundez/b38ebff3ceb2ac5da378e8b9b15c7c4f to your computer and use it in GitHub Desktop.
What queries are running in Azure SQL Database?
SELECT r.session_id
,s.login_name
,c.client_net_address
,s.host_name
,s.program_name
,st.TEXT
,s.STATUS
FROM sys.dm_exec_requests r
INNER JOIN sys.dm_exec_sessions s ON r.session_id = s.session_id
LEFT JOIN sys.dm_exec_connections c ON r.session_id = c.session_id
OUTER APPLY sys.dm_exec_sql_text(r.sql_handle) st
WHERE client_net_address IS NOT NULL
AND TEXT IS NOT NULL
AND s.STATUS = 'running'
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment