what is differences between cursor and stored procedure?

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • mcasaurabhsumit
    New Member
    • Feb 2007
    • 15

    what is differences between cursor and stored procedure?

    hello friend,
    plz. send me the answer of this question.


    what is differences between cursor and stored procedure?
  • Doranj00
    New Member
    • Apr 2007
    • 5

    #2
    A stored procedured is a named bit of saved code that can be run from the database.



    A cursor is a memory structure used to *hold* data from a query run from within a stored procedure (this is REALLY trimming it down).

    A cursor basically is a place to hold the results from a query. A cursor allows you to transverse the result set row by row.

    If you were using analyzer, you could just type the following as view the results:

    Select Userid
    From Usertable

    UserId
    ----------
    User1
    User2
    User3

    Which is real coo, because it has a screen to SEE the resultset.

    But there is no *screen* in a stored procedure because its run automatically. So, you obviously need to do something with data right? How do you access the values of the data? You need to look at it one row at a time....

    so viola - we have cursors. Consider them like a bag. You throw all the results of a query in there and when you need a particular row, just open the bag and grab it!

    Hope it helps!

    Hannah

    Comment

    Working...