Home Forums SQL Server 2008 T-SQL (SS2K8) Query Help- Cursor change into FOR WHILE LOOP, TEMP TABLE RE: Query Help- Cursor change into FOR WHILE LOOP, TEMP TABLE

  • It is true you can make cursors more optimal than a while loop but why bother with them at all? In your examples there is absolutely nothing that can't be done far quicker by getting rid of the loop entirely.

    Exactly @sean, in my example there is nothing one should use a CURSOR.

    This was only to show people who believe that CURSORS are evil and use WHILE loops happily. I'm not favoring CURSORS, but just want to bust that myth.

    Lot of problems can be easily done by SET based approach rather than using CURSORS. People not expert in writing SQL queries and/or not aware of new features end up using CURSORS.