DEV Community 👩‍💻👨‍💻

rajanand ilangovan
rajanand ilangovan

Posted on • Originally published at on

What happens to the records inserted into a table variable, if the transaction rollback?

DECLARE @People TABLE (first_name VARCHAR(50), age int);
INSERT INTO @People VALUES ('John', 25);
INSERT INTO @People VALUES ('Daniel', 30);


SELECT * FROM @People;

Enter fullscreen mode Exit fullscreen mode


The records inserted into a table variable will not be affected by the transaction rollback.


Reference: Brent Ozar

If you like this SQL interview question, you may also like the below interview question and answers.

Top comments (0)

Build Anything...

Use any Linode offering to create something for the DEV x Linode Hackathon 2022. A variety of prizes are up for grabs, inculding $1,000 USD. 👀

→ Join the Hackathon <-