Monday 13 June 2016

Blocking in Transaction in sql server

Blocking occurs if a transaction tries to acquire an executive lock on a resource that another transaction has already lock. The blocked transaction remains blocked until the blocking transaction release the lock.
  

Let’s see the example
I have two transactions and want to update records on the table EMP.
    
There are two windows I opened
Now I am going to run transaction A without commit. This is open transaction.
  
Now I am executing the Transaction B
   
It is still executing. It is locked by Transaction A. So Transaction B is blocked by Transaction A.
When Transaction A is completed then only the transaction will be complete. See now I going to commit the Transaction A. let’s see what happen
  
Once I commit the Transaction A then see the result of the Transaction B.




No comments:

Post a Comment

If you have any doubt, please let me know.

Popular Posts