I am running a stored procedure on SQL2005.
This is what the stored procedure contains
SELECT * FROM Table1 WHERE Id = @IdParam;
If (@@ROWCOUNT = 0)
BEGIN
INSERT INTO Table1 (@IdParam, Value1, Value2, Value3);
END
ELSE
BEGIN
UPDATE Table1 SET Col1 = Value1, Col2 = Value2, Col3 = Value3 WHERE Id = @IdParam;
END
This stored procedure is not called in a transaction.
When 2 or more processes are trying to execute the stored procedure it causes a dead lock sometimes. I am not able to understand why this would cause a dead lock. Any ideas?