deallocate Cursor

  • In a stored procedure i am using cursor inside the BEGIN TRY n END TRY... in CATCH block, how can i know the the cursor is open?.. is there any possible to identify whether the cursor is open or not?... any help pls?

  • Use the CURSOR_STATUS function. See BOL for the parameters and return values.

  • You can also use @@FETCH_STATUS - again, please refer BOL for further details.

    Thanks & Regards,
    Nakul Vachhrajani.
    http://nakulvachhrajani.com

    Follow me on
    Twitter: @sqltwins

  • I'm curious about how @@FETCH_STATUS tells you anything about whether the cursor's open or not. Surely this just tells you about the status of any fetches that have been done.

    Also, since this is a global function, if your cursor hasn't opened, @@FETCH_STATUS could be telling you about some previously used, unrelated cursor.

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

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