Hi @T.Zacks
To find both login name of the user and the query being run, you may check this:
SELECT DB_NAME(resource_database_id)
, s.original_login_name
, s.status
, s.program_name
, s.host_name
, (select text from sys.dm_exec_sql_text(exrequests.sql_handle))
, *
FROM sys.dm_tran_locks dbl JOIN sys.dm_exec_sessions s ON dbl.request_session_id = s.session_id
INNER JOIN sys.dm_exec_requests exrequests on dbl.request_session_id = exrequests.session_id
WHERE DB_NAME(dbl.resource_database_id) = 'dbname'
For more details , please refer to this article: Finding locks on the table and all locking queries
Best regards,
LiHong
If the answer is the right solution, please click "Accept Answer" and kindly upvote it. If you have extra questions about this answer, please click "Comment".
Note: Please follow the steps in our Documentation to enable e-mail notifications if you want to receive the related email notification for this thread.