Just recently, I assisted a partner with an issue they were having creating a new company in Microsoft Dynamics GP 10 – though, I supposed the same could happen with any other version. In the process of creating the company record, almost at the end of all the routines executed by Dynamics Utilities they were getting the error:
Violation of PRIMARY KEY constraint ‘PKSY60100’. Cannot insert duplicate key in object ‘dbo.SY60100’
KB Article 871699 suggests the problem could be that the DYNAMICS database is associated with a database owner (dbo) other than DYNSA. After running the sp_helpdb system stored procedure, it was determined that the database owner of the DYNAMICS database (and other company databases) was indeed ‘sa’. Knowing this obviously helps, and the solution is as simple as changing the database owner back to DYNSA.
The partner then ran the sp_changedbowner system stored procedure to reset the database owner to DYNSA and got the following error:
Msg 15110, Level 16, State 1, Line 1
The proposed new database owner is already a user or aliased in the database
Having gotten this error, we proceeded to drop the DYNSA from the DYNAMICS database as follows:
DROP USER DYNSA;
Having dropped the user from the database, we needed to re-add DYNSA as the database owner of the DYNAMICS database. This time, I decided to try the new ALTER AUTHORIZATION statement as the customer is running Microsoft SQL Server 2008 R2, as sp_changedbowner will be deprecated from SQL Server sometimes soon.
ALTER AUTHORIZATION ON DATABASE::DYNAMICS TO DYNSA;
Once we executed this command, we restarted the company creation process in Utilities and the error was no longer.
If you find yourself in a similar situation then this should definitely help.
Until next post!
Mariano Gomez, MVP