Search code examples
sqlinsertrollback

Rollback insert statement


I have inserted a significant quantity of records into a table. Unfortunately, these records should not have been inserted in this table. Deletion of the records in a one-by-one fashion is not feasible.

How can one rollback the aforementioned records in this situation?


Solution

  • Assuming you were not inside a transaction when you did this, you're going to find the process painful. Not sure what flavour of DBMS you're interested in, but here's some info on SQL Server 2005:

    Rollback transaction using transaction log

    Essentially, the easiest way to do this is to restore your DB from a backup that predates your inserts.