Please start any new threads on our new
site at https://forums.sqlteam.com. We've got lots of great SQL Server
experts to answer whatever question you can come up with.
| Author |
Topic |
|
sqlpgmr
Starting Member
4 Posts |
Posted - 2005-11-30 : 01:14:32
|
| Friends,I've a very basic doubt with Nested transactions (across procedures) in SQL Server and i guess the given below sample code illustarates my doubt well more than my words ..I've a Proc1 like thiscreate procedure sp_proc1asbeginbegin tran sp_proc1insert into tab1 values (1,2)exec sp_proc2 1 if <Some cdn statement>rollback tran sp_proc1elsecommit tran sp_proc1endand called proc sp_proc2 is like thiscreate procedure sp_proc2(@val1 int)asbegin tran proc2update tab2 set col1 = 5IF <some cdn statement>beginrollback tran proc2endelsebegincommit tran proc2endThe pblm is when the 1st proc is executed and when the cdn statement in the 2nd proc is sucess, then it results with the errorFailed to retreive execution plan: Cannot roll back proc2. No transaction or savepoint of that name was found.any suggestions--SQLPgmr |
|
|
TG
Master Smack Fu Yak Hacker
6065 Posts |
Posted - 2005-11-30 : 07:48:57
|
| That kind of error sounds like there is some other problem. Can you post some working DDL/DML that actually generates the error? It can be a simplified version like you have but make it real, executable code against actual tables.Is there any condition where you want one of your transactions to commit and the other to rollback? If not, get rid of the inner transaction. Set a return code or something in your inner sproc that will indicate the "success" status so that the outer knows if it should commit or rollback.Be One with the OptimizerTG |
 |
|
|
|
|
|