sql >> Base de Datos >  >> RDS >> Sqlserver

Manejo de errores con cursor en SQL

Open Cursor
 Fetch Next
        While @@fetch_status = 0
          BEGIN TRY
            BEGIN TRANSACTION
          if (Record found) then Call update Store proc
          else
                  Call Add store proc

          Commit transaction
          End try
          Begin Catch
             if @@Trancount > 0 ROLLBACK TRANSACTION
          END CATCH
 FETCH NEXT