DEV Community

rajanand ilangovan
rajanand ilangovan

Posted on • Originally published at on

What happens to the variable value set during the transaction, if its rollback?

DECLARE @my_age INT = 20;

SET @my_age += 30;

SELECT @my_age;

Enter fullscreen mode Exit fullscreen mode


Even though the transaction is rolled back, the value set to the variable remains same.


Changes to variables aren't affected by the rollback of a transaction.


Microsoft docs

Brent Ozar

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

Top comments (0)

An Animated Guide to Node.js Event Loop

Node.js doesn’t stop from running other operations because of Libuv, a C++ library responsible for the event loop and asynchronously handling tasks such as network requests, DNS resolution, file system operations, data encryption, etc.

What happens under the hood when Node.js works on tasks such as database queries? We will explore it by following this piece of code step by step.