• One undo of a truncate coming right up...

    CREATE TABLE TestingTruncate (SomeUselessColumn varchar(50))

    INSERT INTO TestingTruncate

    SELECT NAME FROM sys.columns

    SELECT * FROM TestingTruncate -- 501 rows

    BEGIN TRANSACTION

    TRUNCATE TABLE TestingTruncate

    SELECT * FROM TestingTruncate -- 0 rows

    ROLLBACK TRANSACTION

    SELECT * FROM TestingTruncate -- 501 rows

    btw, Create and Drop table are fully undoable as well.

    BEGIN TRANSACTION

    DROP TABLE TestingTruncate

    ROLLBACK TRANSACTION

    SELECT * FROM TestingTruncate

    A similar example with create table is left as an exercise to the reader.

    If an operation didn't write log entries for undo, then if that operation was part of a transaction and the transaction failed, the entire database would have to be marked suspect.

    If an operation didn't write log entries for redo then neither mirroring nor log shipping (nor transactional replication) would be able to repeat that operation at the mirror/secondary

    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