Click here to monitor SSC
SQLServerCentral is supported by Red Gate Software Ltd.
 
Log in  ::  Register  ::  Not logged in
 
 
 
        
Home       Members    Calendar    Who's On


Add to briefcase

Begin transaction ........... commit transaction Expand / Collapse
Author
Message
Posted Thursday, March 25, 2010 10:39 AM
Right there with Babe

Right there with BabeRight there with BabeRight there with BabeRight there with BabeRight there with BabeRight there with BabeRight there with BabeRight there with Babe

Group: General Forum Members
Last Login: Wednesday, December 17, 2014 4:09 AM
Points: 761, Visits: 1,083
Hi,


I have this stored procedure:


create stored procedure test
as

Begin

update table xtu set cod ='A'


End


if i execute this stored procedure from inside other stored procedure, like this:

create procedure test2
as
BEGIN

declare @erro as int

begin transaction

exec test
set @erro =@@error

if @erro =0
begin
commit transaction
end
else
rollback transaction
END


If i get an error when executing the procedure test can i rollback the transaction that was made by the procedure test? or should i place a BEGIN TRANSACTION and COMMIT TRANSACTION inside the stored procedure test , so that i can rollback transaction from within procedure test2 if procedure test fails?


Thank you



Post #889999
Posted Thursday, March 25, 2010 10:42 AM


SSCoach

SSCoachSSCoachSSCoachSSCoachSSCoachSSCoachSSCoachSSCoachSSCoachSSCoachSSCoach

Group: General Forum Members
Last Login: Yesterday @ 3:20 PM
Points: 18,064, Visits: 16,099
Look up Try Catch in BOL. That will help you with being able to rollback the transaction.



Jason AKA CirqueDeSQLeil
I have given a name to my pain...
MCM SQL Server, MVP


SQL RNNR

Posting Performance Based Questions - Gail Shaw
Post #890008
Posted Friday, March 26, 2010 3:24 PM
Old Hand

Old HandOld HandOld HandOld HandOld HandOld HandOld HandOld Hand

Group: General Forum Members
Last Login: Wednesday, October 15, 2014 3:22 PM
Points: 381, Visits: 359
Check this, it should answer your question

http://msdn.microsoft.com/en-us/library/ms189336(SQL.90).aspx


EnjoY!
Post #891133
Posted Friday, March 26, 2010 11:29 PM


SSCoach

SSCoachSSCoachSSCoachSSCoachSSCoachSSCoachSSCoachSSCoachSSCoachSSCoachSSCoach

Group: General Forum Members
Last Login: Yesterday @ 3:20 PM
Points: 18,064, Visits: 16,099
GTR (3/26/2010)
Check this, it should answer your question

http://msdn.microsoft.com/en-us/library/ms189336(SQL.90).aspx



This method would allow the OP to place a transaction in both stored procedures (thus nest the transactions).




Jason AKA CirqueDeSQLeil
I have given a name to my pain...
MCM SQL Server, MVP


SQL RNNR

Posting Performance Based Questions - Gail Shaw
Post #891256
« Prev Topic | Next Topic »

Add to briefcase

Permissions Expand / Collapse