Quantcast
Channel: SQL Server Database Engine forum
Viewing all articles
Browse latest Browse all 5123

Update Locks Table vs View

$
0
0


Hi, I have the below view 

CREATE VIEW vwEmployee
AS
SELECT TOP 1 ID, DateAdded
FROM DB1.dbo.tblEmployee WITH (UPDLOCK, READPAST)
ORDER BY ID ASC, DateAdded ASC

when I run something like 

begin transaction
select * from vwEmployee
waitfor delay '00:00:05'
commit

usually there has to be update lock on only 1 row in the table. But I see Update lock on each row of the table. When I run the same query on the table

select top 1 * FROM DB1.dbo.tblEmployee WITH (UPDLOCK, READPAST)  ORDER BY ID ASC, DateAdded ASC

I see the update lock is only on 1 row. So what I m missing here? Can someone please shed light on this? Thank you


Viewing all articles
Browse latest Browse all 5123

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>