Hello. How can I delete an old cursor which appears when I execute the statement
select * from sys.dm_exec_cursors(0) ?
Thanks.
KILL session_id
...or alternatively if you can issue commands against the connection reported in the session_id column (for instance if the problem is with a SSMS connection that you have open) then you can issue:
CLOSE <cursor name>
DEALLOCATE <cursor name>
Chris
|||Thanks a lot.|||Just to add that the first example I gave was really an 'emergency' measure. It would be advisable to track and fix the cause of the problem.
Chris
|||That was exactly what I was looking for, an emergency measure. I couldn't use close and deallocate. I forgot to mention that I am using SQL SERVER 2005. In a stored procedure I commented out a block together with close and deallocate for the respective cursor. The weird thing is that the procedure has only the declaration/definition of the cursor, otherwise there is no reference to it. I realized that it still exists when I received the error "cursor ... already exists". Thanks again for your answer.
No comments:
Post a Comment