How to undo Drop Table Statement

  • I’ve accidentally executed DROP TABLE statement tables and I lost all the data, is there a way I can retrieve my data back?

  • Restore a backup. I hope you have backups.

    Need an answer? No, you need a question
    My blog at https://sqlkover.com.
    MCSE Business Intelligence - Microsoft Data Platform MVP

  • There's no undo command unfortunately!

  • Fetch your latest backup, restore it as a new database, generate the table definition, execute it on the original database, copy the data over.

    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
  • I don't have a backup

  • hoseam (10/18/2013)


    I don't have a backup

    Sorry to hear that.

    Let this be an incentive to implement a backup plan.

    Need an answer? No, you need a question
    My blog at https://sqlkover.com.
    MCSE Business Intelligence - Microsoft Data Platform MVP

  • hoseam (10/18/2013)


    I don't have a backup

    Then you cannot get the table back. I hope this was not production...

    MCSE SQL Server 2012\2014\2016

  • Alternatively, petition for the UNDROP TABLE command to be introduced in SQL Server 2016.

    Hope you found a way to get the table recreated from somewhere.

  • Richard Warr (10/18/2013)


    Alternatively, petition for the UNDROP TABLE command to be introduced in SQL Server 2016.

    UNDROP is not ISO compliant. PICKUP TABLE is what you want to lobby for.

    ---------------------------------------
    elsasoft.org

  • hoseam (10/18/2013)


    I don't have a backup

    Is it also safe to assume that you have no snapshots? Or a copy of the database somewhere else that you can copy the data from, maybe a test environment?

  • Richard Warr (10/18/2013)


    Alternatively, petition for the UNDROP TABLE command to be introduced in SQL Server 2016.

    Hope you found a way to get the table recreated from somewhere.

    Personally I would like to see a $RECYCLEBIN object for SQL Server such as Oracle has. This would be extremely good in such a situation......

  • kevaburg (10/19/2013)


    Richard Warr (10/18/2013)


    Alternatively, petition for the UNDROP TABLE command to be introduced in SQL Server 2016.

    Hope you found a way to get the table recreated from somewhere.

    Personally I would like to see a $RECYCLEBIN object for SQL Server such as Oracle has. This would be extremely good in such a situation......

    It would be a great addition in a development/testing environment, however possibly a waste of resources in a tightly managed production environment.

    Need an answer? No, you need a question
    My blog at https://sqlkover.com.
    MCSE Business Intelligence - Microsoft Data Platform MVP

  • Koen Verbeeck (10/20/2013)


    kevaburg (10/19/2013)


    Richard Warr (10/18/2013)


    Alternatively, petition for the UNDROP TABLE command to be introduced in SQL Server 2016.

    Hope you found a way to get the table recreated from somewhere.

    Personally I would like to see a $RECYCLEBIN object for SQL Server such as Oracle has. This would be extremely good in such a situation......

    It would be a great addition in a development/testing environment, however possibly a waste of resources in a tightly managed production environment.

    You might have a point but only a small one I think.

    The recyclebin only contains the text statement so its size remains compatively small. In contrast to SQL Server, the restoration of a table can be done online meaning no downtime.

    Alternatively, a technology such as FLASHBACK TABLE TO BEFORE DROP could also be a life/job/money saver.

    There a lot of lessons Microsoft could learn from Oracle in this area and I ask myself alot why it hasn't been more seriously addressed.

Viewing 13 posts - 1 through 12 (of 12 total)

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