code_junkie

Properly scoped transactions in Stored Procs

Nov 11th, 2011
109
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.21 KB | None | 0 0
  1. CREATE PROCEDURE theProc
  2. AS
  3. BEGIN
  4.  
  5. BEGIN TRANSACTION
  6.  
  7. -- do some stuff
  8.  
  9. IF @ThereIsAProblem
  10. ROLLBACK TRANSACTION
  11. ELSE
  12. COMMIT TRANSACTION
  13. END
  14.  
  15. BEGIN TRANSACTION
  16. EXEC theProc
  17. COMMIT TRANSACTION
Add Comment
Please, Sign In to add comment