HestonJames
Programmer
Hello Guys,
I'm recieving the error "Violation of UNIQUE KEY constraint 'UK_OUI' Cannot insert duplicate key" when running this query and I cant quite gather why, from my understanding, the query should only insert records from ##MessageStaging which dont already exist in the OUI table.
Any ideas?
Many thanks,
Heston
I'm recieving the error "Violation of UNIQUE KEY constraint 'UK_OUI' Cannot insert duplicate key" when running this query and I cant quite gather why, from my understanding, the query should only insert records from ##MessageStaging which dont already exist in the OUI table.
Code:
INSERT
INTO OUI
( OUI
, Manufacturer )
SELECT LEFT(##MessageStaging.DeviceAddress, 8)
, 'Unknown OUI, ' + CONVERT(VARCHAR(25), GETDATE(), 121)
FROM ##MessageStaging
LEFT OUTER
JOIN OUI
ON OUI.OUI = LEFT(##MessageStaging.DeviceAddress, 8)
WHERE OUI.OUI IS NULL
Any ideas?
Many thanks,
Heston