Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Out of transaction (explicit)

Status
Not open for further replies.

diesirae

Programmer
May 20, 2003
18
AR
-SQL 2000-
Is there any way to do this?

/*Begin*/
BEGIN TRAN

INSERT INTO DBXXX.dbo.Table (Name, LastName)
VALUES ('jjj','aaaa')

BEGIN TRAN LOG_ACTION
INSERT INTO DBXXX.dbo.ProcesLog (ProcId)
VALUES ('IniProc')

COMMIT LOG_ACTION

IF @@ERROR = 0 COMMIT
ELSE ROLLBACK
/*End*/

I need that, if @@ERROR <> 0 the transaction LOG_ACTION to be commited... and nor rolledback...

¿Is there any way to do this? Any command...

Thanks
 
No. The inner transaction is still a part of the outer transaction. Because of this, if you roll back the outer transaction, the inner transaction will also roll back.

I would set the Log_Action info into a variable. Then after your transaction has been commited or rolled back you can issue another command to to the Log insert.

Denny
MCSA (2003) / MCDBA (SQL 2000) / MCTS (SQL 2005)

--Anything is possible. All it takes is a little research. (Me)
[noevil]
 
Excelent!!! Always simplicity is the best way... and this is an example of it...
THANKS!!!!
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top