I have a table which I'm only Insert, Delete and Select (no Updates)
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?