Can cursors cause deadlocks?

  • If a cursor is opened whose records are based on a table, then is it true that the table has some kind of lock as long as the cursor is open? Can this lock on the table cause a deadlock sometime?

  • Yes open cursors which contains objects that are either being updated/inserted/deleted can cause deadlocks within the database. you need to handle them using proper transaction settings

    Cheers,
    Sugeshkumar Rajendran
    SQL Server MVP
    http://sugeshkr.blogspot.com

  • Is this a theoretical question or is there a particular concern about a specific cursor that is troubling you? If you want our help, please provide specifics - preferably the SQL code itself (protecting proprietary/identifying information, of course) and relevant diagnostic messages. Otherwise, I believe that Sugesh Kumar has answered your question.

    Have a great day!

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

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