Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Rollback transaction using transaction log

Would it be possible rollback transactions using Transactionlog file for a particular record?

I am using SQL Server 2005.

like image 594
THEn Avatar asked Jun 30 '09 19:06

THEn


People also ask

How do I rollback a specific transaction?

You just have to write the statement ROLLBACK TRANSACTION, followed by the name of the transaction that you want to rollback.

Which method is used to rollback the transaction?

SQL RollBack ROLLBACK is the SQL command that is used for reverting changes performed by a transaction.

Can we roll back a transaction after it has committed?

COMMIT permanently saves the changes made by the current transaction. ROLLBACK undo the changes made by the current transaction. 2. The transaction can not undo changes after COMMIT execution.


2 Answers

Natively, no. I believe there are some pricey third party tools to do this, though.

Alternatively, you can restore your DB from a backup, and then RESTORE LOGS to a point in time with the STOPAT = '6/30/2009 2:30PM' argument.

There are Apex and SQL Log Rescue available. If your logs aren't in FULL recovery mode, though, you may be up a creek if you can't restore.

like image 72
Eric Avatar answered Oct 14 '22 03:10

Eric


From what I know your options are ApexSQL Log (pricey but has a free trial) or undocumented SQL Server commands such as DBCC Log and fn_dblog.

Any of these will only work if your database was in full recovery mode, in which case SQL Server stores a lot more details in transaction log.

Also I don’t think this works for any type of transaction. I’ve seen people using this technique for reverting insert, update, delete but I’m really sure if it can be used to revert say ALTER TABLE or something like that.

like image 21
Jon Mallow Avatar answered Oct 14 '22 02:10

Jon Mallow