Tuesday, June 8, 2010

T-SQL Puzzle 4 - Can we rollback after TRUNCATE?

You know that TRUNCATE is DDL command and we can't rollback DDL commands as per BOL.
So what will be the output of below query:

CREATE TABLE Test(Col int)
GO

INSERT INTO Test (Col)
VALUES (1), (2), (3)

SELECT * FROM Test

BEGIN TRAN
   TRUNCATE TABLE Test
   SELECT * FROM Test
ROLLBACK TRAN
SELECT * FROM Test

DROP TABLE Test

No comments:

Post a Comment

Note: Only a member of this blog may post a comment.