help on cursor working process

  • I am using a cursor inside my store procedure. This store procedure is performing some opertaions on thousands of records..

    I am executing this stored procudure manually..

    My question:

    If i abort this storedprocedure execution in the middle of the process.. what will happens with the cursor....

  • Krissh_pallu (9/3/2012)


    I am using a cursor inside my store procedure. This store procedure is performing some opertaions on thousands of records..

    I am executing this stored procudure manually..

    My question:

    If i abort this storedprocedure execution in the middle of the process.. what will happens with the cursor....

    Can you please post your script ?

    --rhythmk
    ------------------------------------------------------------------
    To post your question use below link

    https://www.sqlservercentral.com/articles/forum-etiquette-how-to-post-datacode-on-a-forum-to-get-the-best-help
    🙂

  • Yes, post your script so someone can show you that you probably don't need to use a CURSOR.


    My mantra: No loops! No CURSORs! No RBAR! Hoo-uh![/I]

    My thought question: Have you ever been told that your query runs too fast?

    My advice:
    INDEXing a poor-performing query is like putting sugar on cat food. Yeah, it probably tastes better but are you sure you want to eat it?
    The path of least resistance can be a slippery slope. Take care that fixing your fixes of fixes doesn't snowball and end up costing you more than fixing the root cause would have in the first place.

    Need to UNPIVOT? Why not CROSS APPLY VALUES instead?[/url]
    Since random numbers are too important to be left to chance, let's generate some![/url]
    Learn to understand recursive CTEs by example.[/url]
    [url url=http://www.sqlservercentral.com/articles/St

  • Krissh_pallu (9/3/2012)


    I am using a cursor inside my store procedure. This store procedure is performing some opertaions on thousands of records..

    I am executing this stored procudure manually..

    My question:

    If i abort this storedprocedure execution in the middle of the process.. what will happens with the cursor....

    It depends. For example, is SQL Server setup for implicit or explicit transactions. Are there any explicit transactions in the code? If so, are they at the row level or at a higher level?

    So far as what happens to the actual cursor goes and since I think this might be an interview question, please lookup DEALLOCATE in Books Online. The answer is there.

    --Jeff Moden


    RBAR is pronounced "ree-bar" and is a "Modenism" for Row-By-Agonizing-Row.
    First step towards the paradigm shift of writing Set Based code:
    ________Stop thinking about what you want to do to a ROW... think, instead, of what you want to do to a COLUMN.

    Change is inevitable... Change for the better is not.


    Helpful Links:
    How to post code problems
    How to Post Performance Problems
    Create a Tally Function (fnTally)

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

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