26.02.2015 Views

DOT NET Interview Questions - DotNetSpider

DOT NET Interview Questions - DotNetSpider

DOT NET Interview Questions - DotNetSpider

SHOW MORE
SHOW LESS

You also want an ePaper? Increase the reach of your titles

YUMPU automatically turns print PDFs into web optimized ePapers that Google loves.

(B)What are the problems that can occur if you do not<br />

implement locking properly in SQL SERVER ?<br />

Following are the problems that occur if you do not implement locking properly in SQL<br />

SERVER.<br />

Lost Updates<br />

Lost updates occur if you let two transactions modify the same data at the same time, and<br />

the transaction that completes first is lost. You need to watch out for lost updates with<br />

the READ UNCOMMITTED isolation level. This isolation level disregards any type of<br />

locks, so two simultaneous data modifications are not aware of each other. Suppose that<br />

a customer has due of 2000$ to be paid.He pays 1000$ and again buys a product of<br />

500$.Lets say that these two transactions are now been entered from two different counters<br />

of the company.Now both the counter user start making entry at the same time 10:00<br />

AM.Actually speaking at 10:01 AM the customer should have 2000$-1000$+500 = 1500$<br />

pending to be paid.But as said in lost updates the first transaction is not considered and<br />

the second transaction overrides it.So the final pending is 2000$+500$ = 2500$.....I hope<br />

the company does not loose the customer.<br />

Non-Repeatable Read<br />

Non-repeatable reads occur if a transaction is able to read the same row multiple times<br />

and gets a different value each time.Again, this problem is most likely to occur with the<br />

READ UNCOMMITTED isolation level. Because you let two transactions modify data<br />

at the same time, you can get some unexpected results. For instance, a customer wants to<br />

book flight , so the travel agent checks for the flights availability.Travel agent finds a seat<br />

and goes ahead to book the seat.While the travel agent is booking the seat , some other<br />

travel agent books the seat.When this travel agent goes to update the record , he gets<br />

error saying that “Seat is already booked”.In short the travel agent gets different status at<br />

different times for the seat.<br />

Dirty Reads<br />

Dirty reads are a special case of non-repeatable read. This happens if you run a report<br />

while transactions are modifying the data that you're reporting on. For example there is a<br />

customer invoice report which runs on 1:00 AM in afternoon and after that all invoices<br />

are sent to the respective customer for payments.Lets say one of the customer has 1000$<br />

201

Hooray! Your file is uploaded and ready to be published.

Saved successfully!

Ooh no, something went wrong!