Capture cursor SQL for long running queries
It would be great if SQL Monitor would capture the SQL statement being executed for long-running cursors. Currently it shows "FETCH CURSORNAME001"
Cursor SQL can be found with this query when the cursor is still open:
SELECT c.sessionid,
c.cursorid,
c.properties,
c.creationtime,
c.isopen,
c.fetchstatus,
c.dormantduration,
s.logintime,
t.text
FROM sys.dmexeccursors (0) c
JOIN sys.dmexecsessions s
ON c.sessionid = s.sessionid
CROSS APPLY sys.dmexecsqltext(c.sql_handle) t
14
votes
Dag Calafell
shared this idea