Posts

Showing posts with the label Rollbacke

Rollback Table after Truncate Command in Sql Server

Image
It is misconception among people that Truncate cannot be rolled back. But in reality Truncate operation can be Rolled Backed before Commit.Here is the Sql query -- Create table  CREATE TABLE Employee                   ( EmpID INT PRIMARY KEY ,                     EmpSalary INT                   ) -- Check data before Truncate SELECT * FROM Employee --Begin  Transaction BEGIN TRAN --Truncate Table TRUNCATE TABLE Employee GO --Check data after Truncate SELECT * FROM Employee GO --Rollback Transaction ROLLBACK TRAN GO --Check the data after Rollback SELECT * FROM Employee GO Note:- If Transaction is done, mean Committed...