Force row level lock on insert


Is there a way to force  row level lock on insert.
I have a deadlock scenario when one of the processes gets an exclusive lock on one of the tables when performing insert statement that uses the WITH ROWLOCK hint.
It seems that SQL Server ignores my hint and use an  exclusive  lock.

Is there any way to prevent that ?

LVL 19
Who is Participating?
Om PrakashConnect With a Mentor Commented:
You can use row-level locks in SELECT, UPDATE, and DELETE statements.
cyberkiwiConnect With a Mentor Commented:
Your insert may be with [exclusive] rowlock, but it can get put into a page that is being select-ed from another query, which will still trip on the lock (even on 1 row).

insert : insert tbl values (3,4,5..)  -- as part of big transaction
select : select * from tbl where id > 2
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.