If you’re doing CURSOR development for Sql Server to solve business problems, then STOP.
DOWNLOAD this file (right-click and save-as works best) for an example of non cursor based logic solving.
03 and 04 solve the
same business problem, but 2 different ways.
03 is the cursor
model. 04 is the udf model.
Read the comments, and try to make a decent sized database (row count) so you see the massive and significant time difference.