title: Transaction within a cursor
body: <p>Is the following the correct way to use transactions within a cursor:</p>
  
  <pre><code>SET CURSOR_CLOSE_ON_COMMIT ON;
  
  DECLARE cur CURSOR LOCAL FOR 
      SELECT * FROM @ordersToProcess;
  OPEN cur;
  
  DECLARE @OrderId int;
  
  FETCH NEXT FROM cur INTO @OrderId;
  WHILE @@FETCH_STATUS = 0 BEGIN
      BEGIN TRY
          BEGIN TRAN;
          EXEC process_order @OrderId;
          COMMIT TRAN;
          DEALLOCATE cur;                 
          SET CURSOR_CLOSE_ON_COMMIT OFF;
      END TRY
      BEGIN CATCH
          ROLLBACK TRAN;
          DEALLOCATE cur;
          SET CURSOR_CLOSE_ON_COMMIT OFF;
          THROW;
      END CATCH;  
  
      FETCH NEXT FROM cur INTO @OrderId;
  END;
  </code></pre>