• Although not considered "standard", I prefer this approach because (1) the FETCH only has to be written once (can't count the number of times someone changes only one FETCH when there are two causing issues and (2) it's much easier to skip to the next row because you don't have to issue a FETCH before exiting the logic (which can cause even more than 2 FETCHes to be used!).


    DECLARE ... CURSOR ...

    OPEN @db_cursor;

    WHILE 1 = 1
    BEGIN
      FETCH NEXT FROM ... INTO ...;
      IF @@FETCH_STATUS <> 0
          IF @@FETCH_STATUS = -1
              BREAK
          ELSE
              CONTINUE;
      IF <the_current_row_doesn't_need_processed>
          CONTINUE;
      ...process_the_current_row_here...
    END /*WHILE*/

    DEALLOCATE @db_cursor;

    SQL DBA,SQL Server MVP(07, 08, 09) A socialist is someone who will give you the shirt off *someone else's* back.