Suppose we have an Employee Table with these ID ,Name, DeptID, Status and Salary fields.
BEGIN TRAN
TRUNCATE TABLE Employees
ROLLBACK
SELECT * FROM Employees
Suppose we have an Employee Table with these ID ,Name, DeptID, Status and Salary fields.
BEGIN TRAN
TRUNCATE TABLE Employees
ROLLBACK
SELECT * FROM Employees
Know the answer? Post it — somebody with the same question will find it here.
Sign in to answer this question
It is the same account you read, post and publish with — and you will come straight back to this page.
Amit MohantyPosted Feb 28, 2023, 1:28 PM
The query first starts a transaction using BEGIN TRAN, then truncates the Employees table using TRUNCATE TABLE. However, because the transaction is rolled back using ROLLBACK, any changes made to the table during the transaction are undone and the table is restored to its original state.
So it returns result set of all records in the Employees table.
Jignesh KumarPosted Mar 2, 2023, 4:15 AM
Hello Rajeev,
Nothing will happen in above query as you are doing rollback after transaction
Sachin SinghPosted Mar 1, 2023, 2:47 PM
You will get all rows,
No row will be deleted, transaction will roll-back.
Alpesh ManiyaPosted Mar 1, 2023, 2:19 PM
Truncate can't be a rollback, If you have delete a statement then you can rollback.