Save Data Within a Transaction

  • I had a situation where I was running some inserts within a transaction, and needed to issue ROLLBACK because the results did not seem right. I wanted to save some of the results of the inserts to a "save" table somehow, but of course I can't write to a separate table, because the ROLLBACK will undo that also. Is there a way to write/save data somehow, that will not be affected by the rollback ??

  • Table variable. Insert into the table variable during the transaction. Table variables aren't affected by explicit rollbacks, after the rollback you can then insert the data into a permanent table.

    Gail Shaw
    Microsoft Certified Master: SQL Server, MVP, M.Sc (Comp Sci)
    SQL In The Wild: Discussions on DB performance with occasional diversions into recoverability

    We walk in the dark places no others will enter
    We stand on the bridge and no one may pass
  • Thanks

Viewing 3 posts - 1 through 2 (of 2 total)

You must be logged in to reply to this topic. Login to reply