Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    text
    copied!<p>Use <a href="http://msdn.microsoft.com/en-us/library/ms188378.aspx" rel="nofollow noreferrer"><code>SAVEPOINT</code>s</a>, e.g.</p> <pre><code>BEGIN TRANSACTION EXEC myLogSP SAVE TRANSACTION savepointA EXEC @err = myBusinessSPa IF (@err &lt;&gt; 0) BEGIN ROLLBACK TRANSACTION savepointA COMMIT RETURN -1 END EXEC myLogSP SAVE TRANSACTION savepointB EXEC @err = myBusinessSPb IF (@err &lt;&gt; 0) BEGIN ROLLBACK TRANSACTION savepointB COMMIT RETURN -1 END EXEC myLogSP SAVE TRANSACTION savepointC EXEC @err = myBusinessSPc IF (@err &lt;&gt; 0) BEGIN ROLLBACK TRANSACTION savepointC COMMIT RETURN -1 END EXEC myLogSP COMMIT TRANSACTION </code></pre> <hr> <p><strong>EDIT</strong></p> <p>Based on the information provided so far (and my understanding of it) it appears that you will have to re-engineer you logging SPs, either to use variables, or to use files, or to allow them to run 'after the fact' as follows:</p> <pre><code>BEGIN TRANSACTION SAVE TRANSACTION savepointA EXEC @err = myBusinessSPa IF (@err &lt;&gt; 0) BEGIN ROLLBACK TRANSACTION savepointA EXEC myLogSPA -- the call to myBusinessSPa was attempted/failed COMMIT RETURN -1 END SAVE TRANSACTION savepointB EXEC @err = myBusinessSPb IF (@err &lt;&gt; 0) BEGIN ROLLBACK TRANSACTION savepointB EXEC myLogSPA -- the call to myBusinessSPa originally succeeded EXEC myLogSPB -- the call to myBusinessSPb was attempted/failed COMMIT RETURN -1 END SAVE TRANSACTION savepointC EXEC @err = myBusinessSPc IF (@err &lt;&gt; 0) BEGIN ROLLBACK TRANSACTION savepointC EXEC myLogSPA -- the call to myBusinessSPa originally succeeded EXEC myLogSPB -- the call to myBusinessSPb originally succeeded EXEC myLogSPC -- the call to myBusinessSPc was attempted/failed COMMIT RETURN -1 END EXEC myLogSPA -- the call to myBusinessSPa succeeded EXEC myLogSPB -- the call to myBusinessSPb succeeded EXEC myLogSPC -- the call to myBusinessSPc succeeded COMMIT TRANSACTION </code></pre>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload