Reading rows from table using cursors.

  • I have not used SQL Cursors so far.

    I need help with script to read rows from a temporary table using cursors.

    Please help.

    Thanks very much.

  • Before talking about how to write a cursor we should talk about what you'd like to do. In most cases a cursor can (and should) be avoided.



    Lutz
    A pessimist is an optimist with experience.

    How to get fast answers to your question[/url]
    How to post performance related questions[/url]
    Links for Tally Table [/url] , Cross Tabs [/url] and Dynamic Cross Tabs [/url], Delimited Split Function[/url]

  • I want to use CURSOR, which will be scanning the temporary table.

    So with cursor you will be reading the temporary table row by row. Then I have to compare TypeID of the current row with TypeID of the previous row and accumulate unavailability time as I advance through the table.

    I know there are other ways of doing it, but due to the requirement it has to be done using CURSORS.

  • Sql_query (1/6/2010)


    I know there are other ways of doing it, but due to the requirement it has to be done using CURSORS.

    You've just aroused my curiosity. What is the requirement that says you have to use cursors???

    +--------------------------------------------------------------------------------------+
    Check out my blog at https://pianorayk.wordpress.com/

  • Sounds like test or homework...

    I can't think of a valid business rule to refuse good performing code...

    Sorry, but I can't help here!



    Lutz
    A pessimist is an optimist with experience.

    How to get fast answers to your question[/url]
    How to post performance related questions[/url]
    Links for Tally Table [/url] , Cross Tabs [/url] and Dynamic Cross Tabs [/url], Delimited Split Function[/url]

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

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