Occasional Deadlock.

Posted by Carl Robinson on Stack Overflow See other posts from Stack Overflow or by Carl Robinson
Published on 2008-12-01T01:31:34Z Indexed on 2010/04/16 18:33 UTC
Read the original article Hit count: 642

Im having trouble with a web application that will deadlock occasionally

There are 3 queries involved. 2 are trying to update a table

UPDATE AttendanceRoll
SET ErrorFlag = 0
WHERE ContractID = @ContractID
AND DATEPART(month,AttendanceDate) = DATEPART(month,@Month_Beginning)
AND DATEPART(year,AttendanceDate) = DATEPART(year,@Month_Beginning)

and one is trying to insert into the table

INSERT INTO AttendanceRoll 
    (AttendanceDate, ContractID, PersonID, 
    StartTime, 
    EndTime, 
    Hours, AbsenceReason,
    UpdateCount, SplitShiftID, ModifiedBy, ModifiedDate)
SELECT   
    @P33,  @P34,  @P35,
    CONVERT(datetime,REPLACE( @P36 ,'.',':')),
    CONVERT(datetime,REPLACE( @P37 ,'.',':')),
    @P38,  @P39,  
    @P40, 1,  @P41, GETDATE()

The deadlock graph shows a kind of circular arangement of page locks and an exchange event and the 2 update queries have the same server process id.

If anyone has any ideas about how I should go about solving this issue it would be most appreciated.

I have the deadlock graph that I can post if anybody needs to see it.

Thanks Carl R

© Stack Overflow or respective owner

Related posts about sql-server

Related posts about sql-server-2005