title: Error Handling with Cursor in SQL
body: <p>I have cursor which either Update table or Add data if record don't exist. My requirement is </p>
  
  <pre><code>OPEN CURSOR
       Fetch Next
          While @@fetch_status = 0
            if (Record found) then 
                call update stored procedure
            else
                call Add stored procedure
  </code></pre>
  
  <p>Now, issue I am having is, both update/add stored procedure call multiple other stored procedures to do operation. If anything wrong with any other stored procedure, I need to rollback everything</p>
  
  <p>I did try with <code>Begin Transaction</code> and checking if <code>@@Error</code> but it didn't work.</p>
  
  <p>Any help? I am using SQL Server 2008</p>