To answer your question directly:
I have yet to face a situation where the given operations could not do what otherwise could be done with the help of cursors. Nevertheless, there are situations when using cursors to break a large set of problems into more manageable fragments proves a better solution for the convenience of code maintenance, logging, transaction management, etc. But I doubt that there are strict rules that will tell you what types of requirements can lead to one solution or another - individual databases and needs are simply too diverse.
Nevertheless, I completely agree with your approach "if it has not broken, do not correct it." Reorganizing procedural code is not enough to establish operations for a procedure that works very well. However, the correct rule is to first look for a solution based on a set and only if necessary access the process code. Do you feel If you use cursors more than 20% of the time, you are doing something wrong.
And for what I really want to say:
When I interview programmers, I always throw them some moderately complex SQL questions and ask them to explain how they will solve them. These are problems that, as I know, can be solved with the help of given operations, and I am specifically looking for candidates who can solve them without procedural approaches (i.e. Cursors).
This is not because I believe that in any approach there is something inherently good or more effective - different situations give different results. Rather, because, in my experience, programmers either get a concept of set-based operations or not. If they do not, they will spend too much time developing complex procedural solutions for tasks that can be solved much faster and simply using operations with settings.
And vice versa, a programmer who receives operations with a set almost never encounters problems with a procedural solution when it is really necessary.
Michael ames
source share