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

locking and not locking

$
0
0

One connection starts a transaction and selects with xlock:

select * from mytable with (xlock);

Another connection tries to read and succeeds:

select id from mytable;

Another connection tries to read and blocks:

select * from mytable;

I thought the xlock would block all reads, but it is not blocking these on an indexed field.

Is that right?

If I use (tablockx) it does block the ID.

This is all on SQL 2016.

Thanks,

Josh


Viewing all articles
Browse latest Browse all 5123

Trending Articles



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