Thursday, February 3, 2011

Reading Uncommited data In SQL Server

Most of the time when we want to do an update, delete or insert to the database we use begin, rollback SQL statements.
If only you are very sure that you will be using commit tran.

Why we use rollback tran is to make sure that what ever that we do has not caused the data in the DB to be in inconsistent state. Lets take a look at the below example.

1. begin tran
2. update HumanResources.Employee
3. set NationalIDNumber = 60
4. where EmployeeID = 257
5. rollback tran

If your transaction is not completed then you will not be able to check the changes in the data in the DB as the changes have not been committed yet.

During such times you can run the below statement and get this job done.

set transaction isolation level read uncommitted

No comments:

Post a Comment

Retrieving Calendar of a Bookable Resource in Dynamics

There are occasions where we need to retrieve working days and working times of a resource in Dynamics grammatically. This is quite possible...