• steve.bailey 29413 (6/5/2014)


    TRUNCATE TABLE isn't a fully logged operation but as Sujeet's findings show it is logged in the transaction log (It's always logged regardless of recovery model - I'd be very concerned if it wasn't) so you can roll it back provided that you haven't committed the transaction that included the TRUNCATE TABLE statement. This doesn't mean that it logs all the rows in the table in the transaction log like the DELETE statement (if it did it wouldn't be as immediate as it is). If you do commit the transaction, the only way to recover the contents of the table is to perform a point in time restore from backup (just like Sujeet indicated). If you are using the simple model, it will still be logged and can be rolled back, you just won't be able to perform a point in time restoration of the database (unless that point in time happens to be when you performed a full backup of the database).

    According to Kalen Delaney it doesn't quite fit into the minimally logged category either...

    http://sqlblog.com/blogs/kalen_delaney/archive/2010/10/12/tsql-tuesday-11-rolling-back-truncate-table.aspx

    Way to fill in the gaps.

    Glad you discussed the "fully" logged issue too. 😎

    Jason...AKA CirqueDeSQLeil
    _______________________________________________
    I have given a name to my pain...MCM SQL Server, MVP
    SQL RNNR
    Posting Performance Based Questions - Gail Shaw[/url]
    Learn Extended Events