Get input buffer information for the current database

Get input buffer information from all non-system sessions for the current database

SELECT es.session_id
	,DB_NAME(es.database_id) AS [Database Name]
	,es.login_time
	,es.cpu_time
	,es.logical_reads
	,es.memory_usage
	,es.[status]
	,ib.event_info AS [Input Buffer]
FROM sys.dm_exec_sessions AS es WITH (NOLOCK)
CROSS APPLY sys.dm_exec_input_buffer(es.session_id, NULL) AS ib
WHERE es.database_id = DB_ID()
	AND es.session_id > 50
	AND es.session_id <> @@SPID
OPTION (RECOMPILE);

Related

DBCC INPUTBUFFER

dm_exec_input_buffer,New DMF for retrieving input buffer

Spread the love