Tuesday, February 7, 2012

Rollbacking Truncated Table

 

Question is can you rollback truncated table. If so is there any specific recovery model.

Answer is yes you can rollback truncated table what ever the recovery model you have.

Here is the demo.

CREATE TABLE TblData
(ID INT IDENTITY,
Date Datetime DEFAULT GETDATE()
)

INSERT TblData
DEFAULT VALUES
GO 1000

So we have a table of 1000 records.

BEGIN TRAN

TRUNCATE TABLE TblData

If you do a count table will have 0 records,

Now you issue a ROLLBACK statement and you will be end up 1000 records which means rollback was successful.

No comments:

Post a Comment