• What I've found most useful when designing set-based vs row-based coding, is a few tips:

    1. Assume rows don't have an order to them. So you can't do "row 1, then row 2, then row 3". Do rows 1-3 all at once.

    2. Treat sets of rows as a single object, and call methods against them, instead of doing something procedural to individual rows. Methods include calculations, aggregations, CRUD, and so on. Think of the From clause in a query as defining the object, and the other clauses (Select, Update, Where, Order By, etc.) as methods against that set-of-rows object.

    3. The concept of working against columns instead of rows also helps.

    There's more to it, but that's a good start.

    - Gus "GSquared", RSVP, OODA, MAP, NMVP, FAQ, SAT, SQL, DNA, RNA, UOI, IOU, AM, PM, AD, BC, BCE, USA, UN, CF, ROFL, LOL, ETC
    Property of The Thread

    "Nobody knows the age of the human race, but everyone agrees it's old enough to know better." - Anon