The transaction may have been included due to previous or possible future code, which may include other data. Perhaps this developer is just making the habit of wrapping code in transactions to be “safe”?
But if the statement literally only includes one update per line, then there is no benefit to this code. A transaction does not necessarily “block” anything, although actions performed within it may, of course. It simply ensures that all the actions contained in it are performed all or nothing.
Note that a transaction is not about multiple tables - it is about multiple updates. Ensuring that multiple updates occur or not.
So, if you update the same table twice, there will be a difference with or without a transaction. But your example shows only one update statement, supposedly updating only one record.
In fact, it is probably quite common that transactions encapsulate multiple updates in the same table. Imagine the following:
INSERT INTO Transactions (AccountNum, Amount) VALUES (1, 200) INSERT INTO Transactions (AccountNum, Amount) values (2, -200)
This must be enclosed in a transaction to guarantee the correct transfer of money. If someone fails, then another.
source share