Hi
I am using the Professional Services Tool to consolidate vendor ID’s in SL7. When I do so I often get the below constraint violation for vendor id’s on the APHist and Inactive_vendor tables. I’m not sure if deleting the entries on either of these tables for the id’s in question is a good idea for enabling the consolidation of the vendor records. Has anyone run into this before?
ERROR: Violation of Primary Key constraint ‘PK-Inactive_Vendor’ Cannot insert duplicate key in object ‘dbo.Inactive_Vendor’.
The duplicate key value is (xxxxxxxxxx). The statement is terminated.
*This post is locked for comments
Hi Doug,
I did sp_help on the APHIST table and did find the primary keys that are on that table.
So if you know the vendor that you are getting this error you we can check the aphist table for the 3 fields to see if there are any duplicates.
APHist0 clustered, unique, primary key located on PRIMARY VendId, CpnyID, FiscYr
Please look at the aphist table to see if there are any duplicates for the vendor that is getting the error when you are combining the information.
select * from aphist where vendid = 'XXXXXX'
--replace XXXXXX with the vendors ID,
Make sure to look at the vendid, cpnyid, and fiscyr fields to see if there may be any data that is not correct.
A unique key violation can occur if you try to insert a record that already exists, but it can also occur if you try to insert a record with a blank key value. As an example, on APHist, the unique key is company ID, vendor ID, and fiscal year. If you tried to insert a record for vendor SMITH, company A, fiscal year 2007 and there was already a record with those key values, you would get a unique key violation. If you tried to insert a record for vendor SMITH, fiscal year 2007, and no company ID, you would also get an error.
Stay up to date on forum activity by subscribing. You can also customize your in-app and email Notification settings across all subscriptions.
André Arnaud de Cal... 291,240 Super User 2024 Season 2
Martin Dráb 230,149 Most Valuable Professional
nmaenpaa 101,156