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.

 All Forums
 General SQL Server Forums
 New to SQL Server Programming
 Exceptions handling in SQL

Author  Topic 

aakcse
Aged Yak Warrior

570 Posts

Posted - 2010-04-16 : 11:18:39
Hi all,

one quick question,

If have a code as below If any exeption is raised, the cursor will go to catch block and execute it, before that It will roll back all the dml in begin try and end try, or I need to explicitly mention in the catch block to roll back.



begin try
......
end try

begin catch
...
end catch

Thanks
ak

-Neil

Transact Charlie
Master Smack Fu Yak Hacker

3451 Posts

Posted - 2010-04-16 : 11:20:19
you have to rollback in the catch block. (assuming you want to)


Charlie
===============================================================
Msg 3903, Level 16, State 1, Line 1736
The ROLLBACK TRANSACTION request has no corresponding BEGIN TRANSACTION
Go to Top of Page

Transact Charlie
Master Smack Fu Yak Hacker

3451 Posts

Posted - 2010-04-16 : 11:26:36
You should probably read these:
http://www.sqlteam.com/article/handling-sql-server-errors

and
http://msdn.microsoft.com/en-us/library/ms179296.aspx


Charlie
===============================================================
Msg 3903, Level 16, State 1, Line 1736
The ROLLBACK TRANSACTION request has no corresponding BEGIN TRANSACTION
Go to Top of Page

aakcse
Aged Yak Warrior

570 Posts

Posted - 2010-04-16 : 11:30:56
yes exactly I am getting this error

Msg 3903, Level 16, State 1, Line 1736
The ROLLBACK TRANSACTION request has no corresponding BEGIN TRANSACTION

-Neil
Go to Top of Page

Transact Charlie
Master Smack Fu Yak Hacker

3451 Posts

Posted - 2010-04-16 : 11:37:14
post the complete code. You've probably got a nested rollback or something.


Charlie
===============================================================
Msg 3903, Level 16, State 1, Line 1736
The ROLLBACK TRANSACTION request has no corresponding BEGIN TRANSACTION
Go to Top of Page
   

- Advertisement -