i like to know what is the use of these keyword in sql server (UPDLOCK, ROWLOCK READPAST)
and when to use it? i mean in what kind of situation people go for (UPDLOCK, ROWLOCK READPAST)
.
1) select top 1 COMMAND
from EXAMPLE_TABLE
with (UPDLOCK, ROWLOCK)
where PROCESSED=false;
just see the above sql they use UPDLOCK
, ROWLOCK
what is UPDLOCK
, ROWLOCK
?
what will happen for UPDLOCK
, ROWLOCK
?
2) SELECT TOP(1) COMMAND, PROCESSED
FROM TABLE WITH (READPAST)
WHERE PROCESSED = 0
what is READPAST
? when we use READPAST
then what happen ?
3) UPDATE OrderTable WITH ( ROWLOCK )
SET ProcessorID = @PROCID
WHERE OrderID IN ( SELECT TOP ( 20 )
OrderID
FROM OrderTable WITH ( ROWLOCK )
WHERE ProcessorID = 0)
here the above sql use ROWLOCK
for update statement and also in nested select sub query......why??
what will happen for ROWLOCK
?
it is my request that please explain each point with lots of example in such way as a result i can understand the usage of those keyword. thanks