0

I'm running sp_BlitzCache (Brent Ozar) to get some information about database performance. The program that "attacks" this database uses cursors everywhere, so sp_BlitzCache gives me several lines where Query Text is something like 'FETCH API_CURSOR000000000045E513'. Is there any way to know what the select of that cursor is? Thanks in advance.

2

Sure, Joe Sack writes that you can track it down for live sessions with the help of sys.dm_exec_cursors, like this:

SELECT c.session_id, c.properties, c.creation_time, c.is_open, t.text
FROM sys.dm_exec_cursors (53) c
CROSS APPLY sys.dm_exec_sql_text (c.sql_handle) t

With 53 being a current live session holding a cursor open. You can also use 0 to get all current open sessions.

Granted, this is different than sp_BlitzCache - it's only for currently running queries.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.