how to get the recent query, executed on server

  • i want to get the query which is executed recently on sql server 2000. whts the method for this.

  • sp_who2 will give you the details of the currently running processes. If you know the SPID of the process then you can run DBCC INPUTBUFFER(SPID) to know that command that was issued.

    e.g. DBCC INPUTBUFFER(53).

    Pradeep Adiga
    Blog: sqldbadiaries.com
    Twitter: @pradeepadiga

  • Hi,

    When the query / stored procedure is executed along with the DBCC INPUTBUFFER(SPID), it is giving the query or the stored procedure.

    Is there any method to get the last executed query from a stored procedure?

    [font="Arial"]Nothing is impossible with Hard Work[/font]:)

  • According to me sp_who2, DBCC INPUTBUFFER, querying the SYSPROCESSES table, Running a trace using SQL Profiler are only options to get the last executed query details.

    Regards,

    Pradeep

    Pradeep Adiga
    Blog: sqldbadiaries.com
    Twitter: @pradeepadiga

Viewing 4 posts - 1 through 3 (of 3 total)

You must be logged in to reply to this topic. Login to reply