Sql-server – happening with locks in the database

clockingsql serversql-server-2008

I'm having some problems on my database. At any given time, I'm trying to execute an update with five records on my table, but this table is locked and I get a time out executing the query.

I realized that if I execute update in only four records, the statement run sucessfully. And when I try to update the five recods together, it doesn't work.

Example:

--ONLY LOCKS IF THE UPDATE IS IN ALL FIVE RECORDS. (any combination works fine)

UPDATE X SET STATUS = 1 WHERE ID IN (1,2,3,4,5) -- THIS LOCKS THE UPDATE!!

UPDATE X SET STATUS = 1 WHERE ID IN (2,3,4) -- THIS  DOESN'T LOCK AND RUN SUCESSFULLY!

UPDATE X SET STATUS = 1 WHERE ID IN (1,4,5) -- THIS  DOESN'T LOCK AND RUN SUCESSFULLY!

UPDATE X SET STATUS = 1 WHERE ID IN (1,2,3,5) -- THIS DOESN'T LOCK AND RUN SUCESSFULLY!

Does anyone have an idea to how I fix this situation?

EDIT 1:
My isolation level is Read Commited.

Best Answer

When I run sp_lock, I realized that two locks in my table: PAG and KEY. Searching more about KEY LOCK, I created an index for the column on the where clause, and this solve my problem.

EDIT: When I removed the where clause (without index) , it worked fine too.