Hi @Sudip Bhatt ,
I will provide an example about READPAST.
Create one table with 300 rows.
CREATE TABLE TESTTABLE
(ID int,
SALARY INT
)
DECLARE @i INT
SET @i = 1
WHILE (@i <= 300)
BEGIN
INSERT INTO TESTTABLE VALUES(@i, 100*@I)
SET @i = @i + 1
END
SELECT * FROM TESTTABLE
Then we could have 300 rows of data.
Run below update statement.
BEGIN TRANSACTION
UPDATE TOP(1) TESTTABLE
SET SALARY = SALARY + 1
In another session, run below select statement.
SELECT COUNT(*)
FROM TESTTABLE WITH(READPAST)
Output:
299
This table originally had 300 records in it. The UPDATE statement is currently locking one record in the table. The script above that uses READPAST returns 299 records, which means that because the record I am updating is locked, it is ignored by the READPAST hint.
Best regards
Melissa
If the answer is helpful, please click "Accept Answer" and upvote it.
Note: Please follow the steps in our documentation to enable e-mail notifications if you want to receive the related email notification for this thread.