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 ]
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;
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:
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.
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.