This article is half-done without your Comment! *** Please share your thoughts via Comment ***
In the previous post, I have shared important details about SQL Server DBCC INPUTBUFFER and how we can use it to find a lead blocker transaction.
SQL Server: DBCC INPUTBUFFER to find the last statement executed by a SPID
SQL Server 2016 introduced sys.dm_exec_input_buffer which is a extended version of DBCC INPUTBUFFER.
It is also serving the same service like DBCC INPUTBUFFER.
You can build your full query using this new system dmv.
Prepared a script to find the last statement executed by SPID.
1 2 3 4 5 6 7 8 9 10 |
SELECT der.session_id ,ib.event_info AS QueryText FROM sys.dm_exec_requests AS der JOIN sys.dm_exec_sessions AS des ON des.session_id = der.session_id CROSS APPLY sys.dm_exec_input_buffer(der.session_id, der.request_id) AS ib WHERE des.is_user_process = 1 GO |
Leave a Reply