cursors in stored procedure

  • hi ,

    iam new to sqlserver, but i need to write a stored procedure using cursor. i have field in the application called refno. and referencing to that field i need to capture the other field values for a particular date .The refno. field have a specific value for some application type and other field value changes.

    could u please help me in sorting out this.

    many thanks

  • Hi can you please post the scripts to create the tables you need help with, and some insert statements to populate data into these tables.

    And also what the output is you require. Maybe you don't need a cursor. Cursors are resource intensive and should only be used as a last resort.

    🙂

    ----------------------------------------------------------------------------------------------
    Struggling to find the question?
    http://weblogs.sqlteam.com/jeffs/archive/2008/05/13/question-needed-not-answer.aspx

  • Two things. First, from the description provided it is really difficult to provide you with any real help. Second, why do you think you need a cursor? Most likely you don't. Help us help you, read the first article referenced in my signature block regarding asking for assistance. If you follow the instructions in that article and post DDL for your tables, sample data for the tables, expected results; there are numerous people out here that will jump in to help you, and in return you will get tested code as well.

  • mirravi9 (8/20/2009)


    hi ,

    iam new to sqlserver, but i need to write a stored procedure using cursor.

    If yu just want to know how to create cursor, it's simple.

    You can easily get syntax by searching in google.

    Wel, give us more details so that we can help you out.

    Don't just assume that you must use cursor. Probably it could be done with using cursor also...

  • mirravi9 (8/20/2009)


    but i need to write a stored procedure using cursor

    As the others have stated, "No... you probably don't". The thing is, we need more info about your problem in order to be able to help. With the idea that one picture is worth a thousand words, please read the article at the first link in my signature below and try submitting the problem using the methods in the article. Sure, it'll take a little work on your part, but you'll usually get a fully tested answer in less time than you've already spent.

    --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 5 posts - 1 through 4 (of 4 total)

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