How to identify particular cusor is open or not

  • Hi,

     

    1.I need to know how to identify particular cursor

    is open or not

    2. How to close all the open cursors in one command

     

    Thanks in advance

     

    Ramesh

  • All cursors whether in your scope or not or just those in your scope, either way I believe there is a system XP or SP for that but don't have BOL handy.

  • You must use the Built-in CURSOR_STATUS function to identify whether ur cursor is open or not.

    ex:

    IF Cursor_Status('local','<Cursor name>') >= 0

    CLOSE <Cursor name>

    DEALLOCATE <Cursor name>

    I guess there are no way to close all the open cursors in your program.... So u must check the cursor status and close the cursors at the end of ur program.

     

  • loop through the cursor returned by sp_cursor_list, close and deallocate each open cursor. haven't actually used it; just read in BOL.

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

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