BEGIN TRANTRUNCATE TABLE EmployeesROLLBACKSELECT * FROM Employees
Hi Rajeev Kumar,
The output of the above query, gives 10 records of Employee table.
TRUNCATE will not be affected as it is kept in between BEGIN TRAN and ROLLBACK block
Hope this will help you!
This query will return 10 records as TRUNCATE was executed in the transaction. TRUNCATE does not itself keep a log but BEGIN TRANSACTION keeps track of the TRUNCATE command.
The query you provided includes a transaction that truncates the “Employees” table and then rolls it back. Since the truncation is rolled back, the table will not be empty, and the SELECT statement will retrieve the records that were present before the truncation.
Therefore, the output of the query will be the original records from the “Employees” table. The number of records retrieved will depend on the initial state of the table and the number of records it had before the transaction was executed.
If we do select * from Employees we will find the 10 entries in the table. and after Truncate this will remove all of rows, and since after that immediately we are using rollback, this will revert all of the data and at the end the select satement will provide 10 entries, what it has initially.