I have the following script:
BEGIN
IF NOT EXISTS (SELECT SessionID FROM SessionData WHERE SessionID = @SessionID)
BEGIN
SELECT @RegionID = RegionID
FROM Region
WHERE Domain = @Domain
INSERT INTO SessionData (
SessionID,
SystemID,
RegionID,
RegionDomain,
RemoteAddr,
CreatePage)
VALUES (
@SessionID,
@SystemID,
@RegionID,
@RegionDomain,
@RemoteAddr,
@CreatePage)
END
END
Occasionally the site produces an error as follows:
Violation of PRIMARY KEY constraint 'PK_SessionData'. Cannot insert duplicate key in object 'sbuser.SessionData'. The duiplicate key value is (1h6l61h069srw1nmw73j). Source: Microsoft OLE DB Provider for SQL Server Number: -2147217873
Why does it run the script, if there is a duplicate key..? I am confused.. Any help would be greatly appreciated.
Many thanks..