title: How to continue cursor loop even error occured in the loop
body: <p>I want to insert rows of one table into another. For that I have the below procedure.</p>
  
  <pre><code>ALTER PROCEDURE LOADDATA_a
  AS 
  BEGIN
  
  TRUNCATE TABLE STIDENT_A
  DECLARE @SID INT
  DECLARE @SNAME VARCHAR(50)
  DECLARE @SUB VARCHAR(50)
  DECLARE @MARKS INT
  
  DECLARE LOAD_DATA CURSOR FAST_FORWARD FOR  
  SELECT SID,SNAME,SUB,MARKS 
  FROM student 
  
  OPEN LOAD_DATA   
  FETCH NEXT FROM LOAD_DATA INTO @SID,@SNAME,@SUB,@MARKS
  
  WHILE @@FETCH_STATUS = 0   
  BEGIN
      BEGIN TRANSACTION
  
      INSERT INTO STIDENT_A(SID,SNAME,SUB,MARKS) VALUES (@SID,@SNAME,@SUB,@MARKS)
  
      IF @@ERROR != 0
      BEGIN
          ROLLBACK TRANSACTION
          RETURN
      END
      ELSE
      BEGIN
          COMMIT TRANSACTION
      END
      FETCH NEXT FROM LOAD_DATA INTO @SID,@SNAME,@SUB,@MARKS
  END
  
  CLOSE LOAD_DATA   
  DEALLOCATE LOAD_DATA
  
  END
  </code></pre>
  
  <p>Whenever a row fails to insert, the cursor fails and stops there, but I need it to continue. How to do that?</p>