How to replace Cursor in SQL Server?

What is the best alternative to using a cursor in sql server,considering the performance impacts of using a cursor?

  • Answer:

    It really depends on the query, but the key is to find a set-based solution instead of using the row-by-row processing of a cursor. Another alternative if you can't discern a single set-based query is to use temporary tables and break the process up that way. But that really is a second choice. Without a particular query to address, it's hard to say anything substantive beyond this general advice.

Grant Fritchey at Quora Visit the source

Was this solution helpful to you?

Just Added Q & A:

Find solution

For every problem there is a solution! Proved by Solucija.

  • Got an issue and looking for advice?

  • Ask Solucija to search every corner of the Web for help.

  • Get workable solutions and helpful tips in a moment.

Just ask Solucija about an issue you face and immediately get a list of ready solutions, answers and tips from other Internet users. We always provide the most suitable and complete answer to your question at the top, along with a few good alternatives below.