Quantcast
Channel: SQLServerCentral » SQL Server 2014 » Development - SQL Server 2014 » Latest topics
Viewing all articles
Browse latest Browse all 3145

Doubt in isolation level

$
0
0
Hi there,[code="sql"] IF OBJECT_ID('Emp') is not null begin DROP TABLE Emp end create table Emp(ID int,Name Varchar(50),Salary Int) insert into Emp(ID,Name,Salary) values( 1,'David',1000) insert into Emp(ID,Name,Salary) values( 2,'Steve',2000) insert into Emp(ID,Name,Salary) values( 3,'Chris',3000) [/code]Session 1: [code="sql"]begin tran update emp set Salary=123 where ID=3 waitfor delay '00:00:15' commit[/code]Session 2: run the below query with in 15 sec after running the above query in different query window. [code="sql"]set transaction isolation level read committed select Salary from Emp where ID=3[/code]So this will give output after 15 sec. Because currently transaction is not committed.Now the salary of id 3 is 123.If I again update with the same value for the id. Even if the transaction is not completed session give the output.Try running the same query again. session 2 will not wait for the transaction to complete. What is the reason behind it?

Viewing all articles
Browse latest Browse all 3145

Trending Articles