Undo Last Query

  • Hi,

    Is there a simple way to Rollback (undo) the last query that was performed from Query Analyzer (apart from running a restore) say for example If an update statement was performed without a where clause which consequently updated all the records in a table.

    Cheers

  • In hindsight, no.

    With foresight:

    Do the update with a begin transaction but commit transaction commented out. If you get an unexpected number of records updated then run the commit.

    My personal favourite is to run the query as a select statement complete with WHERE clause. When I am happy that the records and the wouldbe updated value are what they are supposed to be I change the query into an update query.

    Maybe this is a bit long winded but the missing of the WHERE clause is a traditional mistake that is a rite of passage for most SQL Server guys at some stage of their line.

  • A program like log explorer could get one out of that situation. But that involves $$$. David's suggestions is a good one.

    -c

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

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