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
 SQL Server 2005 Forums
 Transact-SQL (2005)
 nested teransaction

Author  Topic 

imranabdulaziz
Yak Posting Veteran

83 Posts

Posted - 2008-06-17 : 09:32:32
Dear all,
i am using sql server 2005.
i have three insert and update statement i want to execute it either entirly or rollback everything.
my question is in this scenario Is i have to write negin tran for every insert or update stmt or IS there any way so that even single tran works for all there insert or update statement

Thank you.

madhivanan
Premature Yak Congratulator

22864 Posts

Posted - 2008-06-17 : 09:34:59

Begin Trans

Insert...
Update...
Insert....
.
.
.
Commit trans

Madhivanan

Failing to plan is Planning to fail
Go to Top of Page

SwePeso
Patron Saint of Lost Yaks

30421 Posts

Posted - 2008-06-17 : 09:35:25
Something similar to
BEGIN TRY
BEGIN TRANSACTION

INSERT...
UPDATE...
INSERT...
DELETE...

COMMIT TRANSACTION
END TRY
BEGIN CATCH
ROLLBACK TRANSACTION
END CATCH



E 12°55'05.25"
N 56°04'39.16"
Go to Top of Page
   

- Advertisement -