DBCC InputBuffer

Download PDF

Being day 17 of the DBCC Command month at SteveStedman.com, today’s featured DBCC Command is DBCC INPUTBUFFER.

Description:

DBCC INPUTBUFFER allows access to the last query run for a specific session (SPID).

DBCC INPUTBUFFER Syntax:

dbcc inputbuffer
(
    session_id [ , request_id ]
)
    [WITH NO_INFOMSGS ]

Example:

The following example we get a list of the sessions, then browse the queries that they have been running.

SELECT *
 FROM master.dbo.sysprocesses P
 ORDER BY spid DESC;

DBCC_InputBuffer

Next if we use one of the SPIDs shown above we can look up the query that was last run as shown below for SPID 55.


DBCC INPUTBUFFER (55);

Which produces the following:

DBCC_InputBuffer2

Which shows us that SPID 55 is running the stored procedure called ReportServer.dbo.GetMyRunningJobs.

Browse around on your own SQL Server and see what you can find.

Notes:

For more information see TSQL Wiki DBCC inputbuffer.

DBCC Command month at SteveStedman.com is almost as much fun as last minute preparation for a SQL Saturday presentation.

Tagged with: ,

Leave a Reply

Your email address will not be published. Required fields are marked *

*

Time limit is exhausted. Please reload CAPTCHA.