1

I have the a UNION query that is using the READPAST query hint. I am wondering if there could be a scenario where the first SELECT could skip a locked row, and but the second SELECT could return that row if that lock has been released during the execution of this query?

The database is using read committed isolation mode.

SELECT
  '1st',
  id
FROM
  supportContacts WITH (READPAST)
WHERE
  type = 'Email'

UNION

SELECT
  '2nd',
  id
FROM
  supportContacts WITH (READPAST)
WHERE
  type = 'Email'

SQL Fiddle

1
  • Yes you are correct. first SELECT could or could not skip a locked row, and but the second SELECT could return that row if that lock has been released. Check my answer to overcome this issue
    – sam
    Dec 17, 2015 at 15:24

1 Answer 1

0

You can use read committed snapshot by using -

alter database xyz
set read_committed_snapshot on

This will give you committed rows. There is no direct way to find out the rows that were not returned by using READPAST hint.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.