Automatic deallocate from Cursors after error

  • Hallo,

    when I have an error duering the cursor operation, I think the cursor will be deallocatet automaticly from SQLServer when the process (reapplication from the SP and new process Id from the server) is closed and all used ressources from SQL Server will be freed.

    If it were so, I dont must explicit Close and deallocate the cursor in the catch block.

    Can someone confirm my mind?

    Thanks and regards

    Uli

  • Hi Uli

    From BOL:

    The cursor is implicitly deallocated when the batch, stored procedure, or trigger terminates, unless the cursor was passed back in an OUTPUT parameter. If it is passed back in an OUTPUT parameter, the cursor is deallocated when the last variable referencing it is deallocated or goes out of scope.

    So yes, you are right.

    Regards

    Lempster

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

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