3/12/2023 Sql server, .
net and c# video tutorial: Phantom reads example in sql server
The Wayback Machine - https://web.archive.org/web/20211021231641/https://csharp-video-tutorials.blogspot.com/2015/08/phantom-reads-ex…
Sql server, .net and c# video tutorial
Free C#, .Net and Sql server video tutorial for beginners and intermediate programmers.
Support us .Net Basics C# SQL ASP.NET Aarvi MVC Slides C# Programs Subscribe Download
Phantom reads example in sql server
Suggested Videos
Part 71 - sql server dirty read example
Part 72 - sql server lost update problem
Part 73 - Non repeatable read example in sql server
Pragim Technologies - Best software
training and placements in marathahalli,
bangalore. For further details please call
09945699393.
Complete Tutorials
How to become a full stack web
developer
Cloud computing complete tutorial
In this video we will discuss phantom read concurrency problem with examples. Healthy food for healthy mind and
body
JavaScript tutorial
Bootstrap tutorial
Angular tutorial for beginners
Angular 5 Tutorial for beginners
https://web.archive.org/web/20211021231641/https://csharp-video-tutorials.blogspot.com/2015/08/phantom-reads-example-in-sql-server.html 1/4
3/12/2023 Sql server, .net and c# video tutorial: Phantom reads example in sql server
Important Videos
The Gift of Education
Web application for your business
How to become .NET developer
Resources available to help you
Dot Net Video Tutorials
Blazor tutorial
C tutorial
ASP.NET Core Tutorial
Phantom read happens when one transaction executes a query twice and it gets a
different number of rows in the result set each time. This happens when a second ASP.NET Core Razor Pages Tutorial
transaction inserts a new row that matches the WHERE clause of the query executed
by the first transaction. Angular 6 Tutorial
We will use the following table tblEmployees in this demo Angular CRUD Tutorial
Angular CLI Tutorial
Angular 2 Tutorial
Design Patterns
SOLID Principles
Scrip to create the table tblEmployees
Create table tblEmployees ASP.NET Web API
(
Id int primary key, Bootstrap
Name nvarchar(50)
) AngularJS Tutorial
Go
jQuery Tutorial
Insert into tblEmployees values(1,'Mark') JavaScript with ASP.NET Tutorial
Insert into tblEmployees values(3, 'Sara')
Insert into tblEmployees values(100, 'Mary') JavaScript Tutorial
The following diagram explains the problem : Transaction 1 starts first. Reads from Charts Tutorial
Emp table where Id between 1 and 3. 2 rows retrieved for first read. Transaction 1 is
doing some work and at this point Transaction 2 starts and inserts a new employee with LINQ
Id = 2. Transaction 1 then makes a second read. 3 rows retrieved for second read,
LINQ to SQL
reulting in phantom read problem.
LINQ to XML
Entity Framework
WCF
ASP.NET Web Services
Dot Net Basics
C#
SQL Server
ADO.NET
ASP.NET
GridView
Phantom read example : Open 2 instances of SQL Server Management studio. From ASP.NET MVC
the first window execute Transaction 1 code and from the second window, execute
Transaction 2 code. Notice that when Transaction 1 completes, it gets different number Visual Studio Tips and Tricks
of rows for read 1 and read 2, resulting in phantom read.
Dot Net Interview Questions
-- Transaction 1
Slides
https://web.archive.org/web/20211021231641/https://csharp-video-tutorials.blogspot.com/2015/08/phantom-reads-example-in-sql-server.html 2/4
3/12/2023 Sql server, .net and c# video tutorial: Phantom reads example in sql server
Begin Transaction Entity Framework
Select * from tblEmployees where Id between 1 and 3
-- Do Some work WCF
waitfor delay '00:00:10'
Select * from tblEmployees where Id between 1 and 3 ASP.NET Web Services
Commit Transaction
Dot Net Basics
-- Transaction 2
C#
Insert into tblEmployees values(2, 'Marcus')
SQL Server
Serializable or any other higher isolation level should solve the phantom read problem.
ADO.NET
ASP.NET
GridView
ASP.NET MVC
Fixing phantom read concurrency problem : To fix the phantom read problem, set Visual Studio Tips and Tricks
transaction isolation level of Transaction 1 to serializable. This will place a range lock on
the rows between 1 and 3, which prevents any other transaction from inserting new
Java Video Tutorials
rows with in that range. This solves the phantom read problem.
Part 1 : Video | Text | Slides
When you execute Transaction 1 and 2 from 2 different instances of SQL Server
Part 2 : Video | Text | Slides
management studio, Transaction 2 is blocked until Transaction 1 completes and at the
end of Transaction 1, both the reads get the same number of rows. Part 3 : Video | Text | Slides
-- Transaction 1
Set transaction isolation level serializable Interview Questions
Begin Transaction C#
Select * from tblEmployees where Id between 1 and 3
SQL Server
-- Do Some work
waitfor delay '00:00:10'
Written Test
Select * from tblEmployees where Id between 1 and 3
Commit Transaction
-- Transaction 2
Insert into tblEmployees values(2, 'Marcus')
Difference between repeatable read and serializable
Repeatable read prevents only non-repeatable read. Repeatable read isolation level
ensures that the data that one transaction has read, will be prevented from being
updated or deleted by any other transaction, but it doe not prevent new rows from being
inserted by other transactions resulting in phantom read concurrency problem.
Serializable prevents both non-repeatable read and phantom read problems.
Serializable isolation level ensures that the data that one transaction has read, will be
prevented from being updated or deleted by any other transaction. It also prevents new
rows from being inserted by other transactions, so this isolation level prevents both non-
repeatable read and phantom read problems.
https://web.archive.org/web/20211021231641/https://csharp-video-tutorials.blogspot.com/2015/08/phantom-reads-example-in-sql-server.html 3/4
3/12/2023 Sql server, .net and c# video tutorial: Phantom reads example in sql server
1 comment:
Unknown August 20, 2015 at 5:15 AM
Hi Venkat;
Can you please come with the example of Using Dynamic SQL Query for PIVOT Table,
Instead of hard code column value for PIVOT Column.
I have come across this example in couple of different web site, but to be honest, i didn't
understand clearly and 100%, because i am sure, i will get 100 % from your demo, if you
can upload ASAP.
Thanks
Rakesh Patel
Reply
It would be great if you can help share these free resources
Newer Post Home Older Post
Subscribe to: Post Comments (Atom)
Powered by Blogger.
https://web.archive.org/web/20211021231641/https://csharp-video-tutorials.blogspot.com/2015/08/phantom-reads-example-in-sql-server.html 4/4