I read that cursors are rather slow , and it is necessary, if only from the options they are not avoided. I am trying to optimize my stored procedures, and one of them uses a cursor. It is often called by my application and many users (20,000) and lines for updating. I thought maybe I should use something else as an alternative.
All I am trying to do or want is to get a list of entries, and then work depending on the value of each row. So, for example, we say -
Employee - Id,Name,BenefitId,StartDate,EndDate
So, based on the benefits. I need to do another calculation using the dates between StartDate and EndDate and update the employee data. I am just doing this far-fetched example to give an idea of my situation.
What do you think about this? Are there better alternatives to cursors, for example, using temporary tables or user-defined functions? When do you really select them or shouldn't use cursors? Thank you all for your help.
source
share