2011-05-11 28 views

回答

1

你可以用整個事情在一個事務中,它會工作,但你必須確保所有的孩子/嵌套的存儲過程將回滾事務,否則你會造成僵局。這樣的事情:

 

Create procedure [dbo].[parent] 
as 
Begin Transaction 
Begin Try 
    Exec Child 
End Try 
Begin Catch 
    If @@Trancount > 0 
     RollBack 
End Catch 
Commit 


Create procedure [dbo].[Child] 
as 
Begin Transaction 
Begin Try 
    --Do inserts here 
End Try 
Begin Catch 
    If @@Trancount > 0 
     RollBack 
    RAISERROR('Error Occured',16,1) 
End Catch 
Commit 

 
+0

好的,得到,謝謝。 – sobsinha 2011-05-12 09:41:28

相關問題