What Could Be Causing The Primary Key Exception?
My ASP pages store session variables in SQL Server with the following stored procedure: CREATE PROCEDURE [dbo].[MyProcedure] @sessionId varchar(512), @variable varc
Solution 1:
Assuming your PK is on sessionId,variable then concurrent executions of the stored procedure with the same @sessionId,@variable could do this.
Both execute the
DELETE Variables WHEREsessionId=@sessionIdANDvariable=@variableline concurrently and then both proceed to the insert.
This could only occur if there is no pre-existing record with the sessionId,variable combination as then the DELETEs would block.
Post a Comment for "What Could Be Causing The Primary Key Exception?"