Displaying SQL statement of a job running

  • Is there a way to view the SQL statement being ran by someone else?  Sometimes a server can hang on an app running a statement on the SQL box and I would like to see what statement is making it hang.

     

    Thanks.

    Alex

  • Use DBCC INPUTBUFFER.  If you do not know the SPID responsible for the hang, you may want to either try to narrow the SPID down by reviewing sp_who2 output, or write code to loop through all current SPIDs and output DBCC INPUTBUFFER for each SPID.

    John Rowan

    ======================================================
    ======================================================
    Forum Etiquette: How to post data/code on a forum to get the best help[/url] - by Jeff Moden

  • Keep in mind that this will only give you the very last statement.  If you need to see more, you may need to run Profiler and try to capture everything that SPID has been doing.

    John Rowan

    ======================================================
    ======================================================
    Forum Etiquette: How to post data/code on a forum to get the best help[/url] - by Jeff Moden

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

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