In this situation many developers tend to use a cursor
Developers resort to using cursors for 2 reasons:
1. The problem domain's complexity makes it difficult for them to envision the set based answer.
2. They do not understand set based thinking.
In this example, the only reason anyone would resort to a cursor would be becuase of #2. This is a very basic update statement and considering a cursor to solve this means that there may be a lack of understanding of working with sets of data.
This is not a slam on you in any way so please don't take this as such, but this is the second post I've seen from you today where cursors were the first choice. As time allows, search through SSC for "set based" and read through the relevent results. Once you condition yourself to see data as sets and work with them as such, using cursors and loops will not even enter into your normal thought process. If you have the desire to be a notch above the masses, think set based.
====================================================== Forum Etiquette: How to post data/code on a forum to get the best help
- by Jeff Moden