SQL Flow Field Guide

DBCC INPUTBUFFER

Catalog support for SQL Server 2022 (16.x) and 2025 (17.x)

diagnostic read

What changes

Input
a session's last input
Output or change
result set

Syntax at a glance

DBCC INPUTBUFFER ( session_id [ , request_id ] ) [ WITH NO_INFOMSGS ]

Work example

An incident responder needs the last submitted command for one session.

Verify the session ID and limit access to the output because command text can contain sensitive values.

Check your work The captured command belongs to the intended session and any sensitive text is redacted.

Open Microsoft Learn for full syntax, permissions, and details for your version.