Find the last query executed by a specific session in Azure SQL Database

Azure SQL Database enables you to check the last query executed by each session. The queries in this article will show you how to do it.

Find a session

First you need to identify a session. Find out more here:

exec sp_who


Result shows eight sessions from host LS-RENECASTRO:

Find the last query

Now we will use session ID (spid) to find the last query issued in this session:

dbcc inputbuffer(<session ID>)


  • EventType - event type. RPC Event means procedure call. Language Event means sql query.
  • Parameters - number of query parameters.
  • EventInfo - last statement executed in the specified session. It returns only the first 4000 characters.

Sample results

Comments are only visible when the visitor has consented to statistics cookies. To see and add comments please accept statistics cookies.
There are no comments. Click here to write the first comment.