ابدأ بالتواصل مع الأشخاص وتبادل معارفك المهنية

أنشئ حسابًا أو سجّل الدخول للانضمام إلى مجتمعك المهني.

متابعة

Can we rollback a committed transaction in Transact SQL? How?

This might not be possible as a part of DML directly, but can we use SQL logs or some filters or anything in the tables to achieve this?

user-image
تم إضافة السؤال من قبل Raghvendra Naik Gaonkar , 1st class , Tabla Examination
تاريخ النشر: 2013/09/19
Mohamed Gad
من قبل Mohamed Gad , Support Developer , Simpl Group

As mentioned earlier, you cannot rollback a transaction that is committed. However, you may use transaction logs to restore the database to an earlier state. In order to do this, you will have to follow the following steps:

1. Take a backup of the transaction log.

2. Restore the Full Backup.

3. Restore the latest differential backup.

4. Restore all transaction log backups until that time.

5. Restore the last transaction log you just took the backup for in step1 and use the Point-in-time feature in order to specify the exact time you want the database to be restored to.

Note that the point-in-time feature is not available if you are using the Simple Backup recovery model for the database. So hopefully you are using the Full Backup recovery model.

rakan haddad
من قبل rakan haddad , Oracle and Databse Developer , Takarub Telecommunication Company

No you cant 

Deepika Kumari
من قبل Deepika Kumari , Software Engineer , Wipro Technologies

It is impossible to rollback after the transaction is commited.

Ganesh Sampat Abdagire
من قبل Ganesh Sampat Abdagire , Senior .NET Developer , Qatar Islamic Bank

No you can not rollback the tranaction once commited.

Ashraf Abu Saed
من قبل Ashraf Abu Saed

Yes you can from sysadmin cancel the workflow and then you can use rollback_transaction procedure to delrte transaction using transaction_id

tariq abbas
من قبل tariq abbas , Professional Services Engineer (Java/Android Developer/Blockchain) , NIFT

once commited can't be rolled back .

Adnan Hamdani
من قبل Adnan Hamdani

You can't rollback any transaction once it is commited. but you need to do backup the database with transaction log. when ever you need to rollback, just restore the last backup with transaction log.

Rajesh K
من قبل Rajesh K , ISP Manager , CENPAC NET INC

Create a snapshot of database, then execute transaction. To undo the transaction, restore from the snapshot

عبدالرحمن محمد صالح احمد عبيد
من قبل عبدالرحمن محمد صالح احمد عبيد , Web & Application Developer , Alkuraimi Bank

I think you can't

the only way is to delete the data that you stored

Daanish Rumani
من قبل Daanish Rumani , Product Manager , Publicis Sapient

You would have to take a backup before starting the transaction and restore it to revert to the previous state.

 

Alternatively you can store only the entire tables that you know are going to be affected and use that to compare rows that were added or removed. You would need to ensure foriegn key relationships are accurately maintained before you do your manual rollback.

المزيد من الأسئلة المماثلة