ComeçarComece de graça

Preventing non-repeatable reads

You are in charge of analyzing data about your bank customers.

You prepare a script that first selects the data of every customer. After that, your script needs to process some mathematical operations based on the result. (We won't focus on these operations for this exercise.) After that, you want to select the same data again, ensuring nothing has changed.

As this is critical, you think it is better if nobody can change anything in the customers table until you finish your analysis. In doing this, you prevent non-repeatable reads.

Este exercício faz parte do curso

Transactions and Error Handling in SQL Server

Ver curso

Instruções do exercício

  • Set the appropriate isolation level to prevent non-repeatable reads.
  • Begin a transaction.
  • Commit the transaction.

Exercício interativo prático

Experimente este exercício completando este código de exemplo.

-- Set the appropriate isolation level
___ ___ ___ ___ ___ ___

-- Begin a transaction
___ ___

SELECT * FROM customers;

-- some mathematical operations, don't care about them...

SELECT * FROM customers;

-- Commit the transaction
___ ___
Editar e executar o código