Displays the last statement sent from a client to Microsoft® SQL Server™.
DBCC INPUTBUFFER (spid)
Is the system process ID (SPID) for the user connection as displayed in the output of the sp_who system stored procedure.
DBCC INPUTBUFFER returns a rowset with the following columns.
|Column name||Data type||Description|
|EventType||nvarchar(30)||Event type, for example: RPC, Language, or No Event.|
|Parameters||Int||0 = text |
1- n = parameters
|EventInfo||nvarchar(255)||For an EventType of RPC, EventInfo contains only the procedure name. For an EventType of Language or No Event, only the first 255 characters of the event are displayed.|
For example, DBCC INPUTBUFFER returns the following result set when the last event in the buffer is DBCC INPUTBUFFER(11).
EventType Parameters EventInfo -------------- ---------- --------------------- Language Event 0 DBCC INPUTBUFFER (11) (1 row(s) affected) DBCC execution completed. If DBCC printed error messages, contact your system administrator.
Note There are very brief transitional periods between events when no event can be displayed on Windows NT®. On Windows 98, an event is displayed only when active.
DBCC INPUTBUFFER permissions default to members of the sysadmin fixed server role only, who can see any SPID. Other users can see any SPID they own. Permissions are not transferable.
This example assumes a valid SPID of 10.
DBCC INPUTBUFFER (10)