7 responses

  1. Barrow
    May 28, 2013

    Thanks for this write-up, Joe. Saved me a ton of time trying to track down a very similar issue earlier today.

    • Joseph Sack
      May 28, 2013

      Most welcome! Glad it was helpful.

  2. Mark Wilkinson
    December 17, 2013

    Just a note. This works great for anything that is in the suspended or runnable queues, but returns nothing if the session is sleeping.

    • Joseph Sack
      December 17, 2013

      Thanks Mark

  3. Robert Eder
    April 21, 2014

    I spent a long time searching for this. I took this one step further to provide more information about who is performing the cursor. Instead of specifying a specific session id, O can be use to list cursors for all sessions. The query I used is as below.

    SELECT c.session_id, es.program_name, es.login_name, es.host_name, DB_NAME(es.database_id) AS DatabaseName, c.properties, c.creation_time, c.is_open, t.text
    FROM sys.dm_exec_cursors (0) c
    LEFT JOIN sys.dm_exec_sessions AS es ON c.session_id = es.session_id
    CROSS APPLY sys.dm_exec_sql_text (c.sql_handle) t

    • Joseph Sack
      April 21, 2014

      Thanks Robert!

Back to top
mobile desktop