How to use nested transaction by other sp | Sololearn: Learn to code for FREE!
New course! Every coder should learn Generative AI!
Try a free lesson
+ 4

How to use nested transaction by other sp

i have 3 stored procedure. SP 1 and 2 for entry data using by Insert statement. SP 3 like below . runner of SP1 and SP2. i need , when exec sp1 or exec sp2 is made a error both of them roll-backing. Begin transaction Execute usp_addproduct @name,@new Execute usp_addproductdetials @itemid,@color Commit transaction Catch if @@TRANCOUNT > 0 rollback

24th Mar 2020, 6:41 AM
Amirhossein Ghasemi
Amirhossein Ghasemi - avatar
1 Answer
+ 1
i'm not sure i usually use trigger for these purposes but try to write it like this : begin try Begin transaction Execute usp_addproduct @name,@new Execute usp_addproductdetials @itemid,@color Commit transaction end try begin Catch if @@TRANCOUNT > 0 rollback transaction end catch
9th Apr 2020, 4:52 PM
Taha Reeh
Taha Reeh - avatar