I have a table in SQL Server having ID column, which is also set as unique clustered index.
I need to determine which records among given IDs are locked as being removed in another transaction.
If I use READPAST I get only those which are not locked, but there is no assurance that the rest of records exist or are being removed in another transaction. NOLOCK with deleted records will not return any data.
The only workaround I found was to execute SELECT with NOWAIT on those IDs which were not retrieved by READPAST and detect lock timeout error, but I need to do that for each record separately.
Is there any faster alternative for that without using system tables or stored procedures?