DEV Community

rajanand ilangovan
rajanand ilangovan

Posted on • Originally published at blog.rajanand.org on

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

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

ROLLBACK

SELECT * FROM @People;

Enter fullscreen mode Exit fullscreen mode

Answer:

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

1118_20220406_004013.png

Reference: Brent Ozar

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

Image of Datadog

The Future of AI, LLMs, and Observability on Google Cloud

Datadog sat down with Google’s Director of AI to discuss the current and future states of AI, ML, and LLMs on Google Cloud. Discover 7 key insights for technical leaders, covering everything from upskilling teams to observability best practices

Learn More

Top comments (0)

Billboard image

The Next Generation Developer Platform

Coherence is the first Platform-as-a-Service you can control. Unlike "black-box" platforms that are opinionated about the infra you can deploy, Coherence is powered by CNC, the open-source IaC framework, which offers limitless customization.

Learn more

👋 Kindness is contagious

Please leave a ❤️ or a friendly comment on this post if you found it helpful!

Okay