Cursor

  • i wanna knw hw 2 create a cursor in sql server 2005 so that i can use to iterate through table rows n while iterating i want to compute some values n view them in the result set....

    so any idea abt that ..??

    Thnx

  • check out Books Online on how to use cursors. Why do you need cursors. They are really performance drags.

    "Keep Trying"

  • Can you explain in more detail what you're trying to do? I'm sure someone will come up with a non-cursor approach.

    Gail Shaw
    Microsoft Certified Master: SQL Server, MVP, M.Sc (Comp Sci)
    SQL In The Wild: Discussions on DB performance with occasional diversions into recoverability

    We walk in the dark places no others will enter
    We stand on the bridge and no one may pass
  • Ya i can explain ..... i have a table called Projects , n another called Individual .. n also other one ProjectIndividuals the Individual has an IndAge as a field i need to have a result Set like this

    ProjectRefNo CategoryName CategoryCount

    1abc <20 100

    2abd <20 50

    1abc 20-30 300 ,,,

    and so on i need to define age ranges and compute counts for all projects

    n categories....

    hope u can understand me ...

    thanks alot

  • Could you please post table creation scripts, sample data and expected output?

    See - http://www.sqlservercentral.com/articles/Best+Practices/61537/

    Gail Shaw
    Microsoft Certified Master: SQL Server, MVP, M.Sc (Comp Sci)
    SQL In The Wild: Discussions on DB performance with occasional diversions into recoverability

    We walk in the dark places no others will enter
    We stand on the bridge and no one may pass
  • hmm i got ur point ..thanks but i really have no time ..

  • With that attitude, please let him use cursors...


    N 56°04'39.16"
    E 12°55'05.25"

  • szahran (8/26/2008)


    hmm i got ur point ..thanks but i really have no time ..

    In that case it's unlikely that anyone will be able to help you properly.

    Gail Shaw
    Microsoft Certified Master: SQL Server, MVP, M.Sc (Comp Sci)
    SQL In The Wild: Discussions on DB performance with occasional diversions into recoverability

    We walk in the dark places no others will enter
    We stand on the bridge and no one may pass
  • ok i will try to ask in a better way next time thnx anyway

Viewing 9 posts - 1 through 8 (of 8 total)

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