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 |
|
AskSQLTeam
Ask SQLTeam Question
0 Posts |
Posted - 2001-11-13 : 19:22:38
|
| Chris writes "I have a process that insert a row into 2 tables, each on different servers. The row is inserted on the remote server via stored procedure for various reasons. When the transaction fails only the row on the local server rolls back, never the row on the remote server. Here's my code:BEGIN TRAN SyncItAll/* Set entire transaction to fail if any runtime error occurs */SET XACT_ABORT ON/* Cram the new stuff into Tbl on Svr.DB */Set Identity_Insert Db.Owner.Tbl On INSERT INTO Db.owner.Tbl (Some columns....)VALUES(Some values...)SET @return_status = @@ERRORIF (@return_status <> 0) BEGIN ROLLBACK TRAN SyncItAll RETURN 1 ENDSet Identity_Insert Db.Owner.Tbl Off/* Jam the new stuff into Tbl on Svr.Db */EXEC Svr.Db.Owner.StoredProcedure @id,@New_GuidSET @return_status = @@ERRORIF @return_status <> 0 BEGIN ROLLBACK TRAN SyncItAll RETURN 1 ENDCOMMIT TRAN SyncItAllThe row inserted by the 'EXEC Svr.Db.Owner.StoredProcedure @id,@New_Guid' line never gets rolled back. What am I doing wrong?Thanks,Chris" |
|
|
|
|
|