I’m getting the above error when running an insert into on one of our tables.
The AdmFormData has 3 primary keys, FormType, KeyField and FieldName.
Would anyone have any ideas what I’m doing wrong?
set rowcount 0
go
INSERT INTO AdmFormData
(
[FormType]
,[KeyField]
,[FieldName]
,[AlphaValue]
,[NumericValue]
,[DateValue]
)
SELECT
'CUS' AS [FormType]
,Customer as [KeyField]
,'SAL001' AS [FieldName]
,[Customer Territory] AS [AlphaValue]
,NULL AS [NumericValue]
,NULL AS [DateValue]
FROM
dgl_territory a
LEFT OUTER JOIN AdmFormData f
on f.FormType = 'CUS' and f.FieldName = 'SAL001' and f.KeyField = a.Customer
WHERE f.FormType IS NULL
The error is telling you that you already have a record in the
AdmFormDatatable that has the primary key you are trying toINSERTIf your primary key on the table contains
FormType, KeyField and FieldNamethen you already have a record with the values:You cannot have more that one record with the same primary key, they are unique.