I have a table which I'm only
Insert
, Delete
and Select
(no Update
s)
on Insert, Sometimes it used a session lock (WITH (TABLOCKX)
)
I have a program using ADO which Select
from the table using the RecordSet::Open
command to open a simple sequential query.
like:
Select * from t1 where id >= @from_id And >= @to_id`
Or:
Select top(10) * from t1 where id >= @id Order by id
The id column is an Identity
column.
When I'm open the query, sometimes I'm getting a deadlock. (the table is locked by the Insert
query and the id column's index is locked by the Select
)
I'm trying to prevent the deadlocks.
Should I open the select queries WITH(NOLOCK)
? may it prevent the deadlocks?
Asked by SHR
(886 rep)
Aug 13, 2019, 05:23 PM
Last activity: Aug 13, 2019, 06:51 PM
Last activity: Aug 13, 2019, 06:51 PM