• SwaroopRaj (4/23/2010)


    yep.. i thought that 'truncate' would never rollback. That was the way i was taught in past. You proved that wrong for me now.

    The thing that trips most people up is the concept that Truncate is "not logged." I hear this concept a lot in discussions and in job interviews. And while it's broadly correct when answering the standard "Why is a Truncate better than a Delete" interview question, it's technically a wrong assumption.

    Truncates are *minimally logged* (EDIT: in ALL database Recovery models), like having your database in Bulk-Logged Recovery Model. That means there are pointers to the pages of the just removed data that can yank that stuff back if needed.

    Deletes are logged more than Truncates, (EDIT: being fully logged in FULL mode down to the row) even in Bulk-Logged mode, because I think (and I could be wrong here) the pointers are more finite, pointing to the actually extents instead of the pages.

    So, yes, a Truncate can absolutely be rolled back. In fact, I'd be hard pressed to say what data change (not schema change) couldn't be rolled back at all.

    Brandie Tarvin, MCITP Database AdministratorLiveJournal Blog: http://brandietarvin.livejournal.com/[/url]On LinkedIn!, Google+, and Twitter.Freelance Writer: ShadowrunLatchkeys: Nevermore, Latchkeys: The Bootleg War, and Latchkeys: Roscoes in the Night are now available on Nook and Kindle.