Basic cursor implementation

  • Post can be deleted, solution has been found. Thanks

  • Couple questions.

    Why do you want to do this with a cursor when a single update statement will do the job perfectly well?

    Why are you denormalising the database? How are you going to keep that CustomerCount column correct as customers are added, deleted and updated?

    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
  • Nice name 🙂

    It is just a fictional, experimental database to mess around with is all. It's ok if it gets messed up a bit. I'm just trying to understand the structure of a cursor as I will be able to relate easier with this sample I've been playing with.

  • Stay away from cursors. They have their place (rarely) but they should not be used when there's a simple set-based alternative, as there is here.

    Are you trying to learn SQL development, including the best way to do various things, or do you want a cursor, even though it's a poor way to solve problems like this?

    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

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

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