web
You’re offline. This is a read only version of the page.
close
Skip to main content

Notifications

Announcements

No record found.

Community site session details

Community site session details

Session Id :
Customer experience | Sales, Customer Insights,...
Answered

Failed to import Dynamics CRM organization

(0) ShareShare
ReportReport
Posted on by 5

Hi there,

I got the following errors while trying to import CRM organization from 1 environment to another environment. I know the custom table that it complained does not have primary key violation. I've also tried to remove all key constraints in DB level before reimporting but didn't work. Hope anyone can share some light. Thanks

15:51:29| Error| The following connections need to be closed before setup can continue:
15:51:29| Error| Login: CRM\crmservice, Host: Win2019.mmc, Database: xxxxxx_MSCRM, User: crmservice, Program: MSCRMmmc
15:51:29|Warning| Check SqlConnectionValidator : Warning: Existing SQL Server connections to the Dynamics 365 databases must be closed before setup can continue.
15:51:29|Verbose| Connecting to database Data Source=Win2019;Initial Catalog=xxxxxx_MSCRM;Integrated Security=SSPI.
15:51:30| Error| Check SqlPrimaryKeyConstraintValidator : Failure: Violation of PRIMARY KEY constraint 'PK__#Invalid__59D49277BDDB8448'. Cannot insert duplicate key in object 'dbo.#InvalidPrimaryKeys'. The duplicate key value is (CustomEntityBase, CustomEntityId).
The statement has been terminated.

I have the same question (0)
  • Suggested answer
    Ken Hubbard Profile Picture
    on at

    Hello Kensi, 

    I believe this exception is that the system is trying to recreate the Primary Key on the table in question, but the primary key that exists is the same and not the expected value so it violates table structure when trying to create the same primary key that exists.  You can try resolve this through the following steps:

    1. In SSMS identify the Primary Key of the table in question through the following query:

    SP_Helpindex [TABLENAME]

    2. Once you identify the name of the Primary Key index you can drop this index through the following SQL query:

    ALTER TABLE [TABLENAME]

    DROP CONSTRAINT [PK_CONSTRAINT]

    After this is complete, run the upgrade again and see if you get past this point. 

  • kensi Profile Picture
    5 on at

    That works!! Thanks

  • melekgoncu Profile Picture
    6 on at
    Hi,
     
    I cannot import (upgrade) the organizations from 8.2 and I got the same error.
    I didn't find ActualDecimal key in GoalBase table. The primary key was PK_GoalBase therefore when I tried DROP CONSTRAINT[PK_GoalBase(It is a default system key)] gave an error in SQL.
    error: "The constraint 'PK_GoalBase' is being referenced by table 'GoalBase', foreign key constraint 'goal_rolluperror_goal'."
     
    Am I trying to drop the wrong CONSTRAINT? Should I try with the name PK__#ActualC__59D492772A37C6B5 ?
    How can I fix it? Thanks.
     
     
    17:27:26|  Error| Check SqlColumnValidator : Failure: Violation of PRIMARY KEY constraint 'PK__#ActualC__59D492772A37C6B5'. Cannot insert duplicate key in object 'dbo.#ActualColumns'. The duplicate key value is (GoalBase, ActualDecimal).
    17:27:26|Verbose| Connecting to database Data Source=XXXXXXX;Initial Catalog=master;Integrated Security=SSPI.
    17:27:26|  Error| The following connections need to be closed before setup can continue:
    17:27:26|  Error|     Login: Domain\user, Host: XXXXXXX.mmc, Database: XXXXX_MSCRM, User: XXX, Program: MSCRMmmc
     

Under review

Thank you for your reply! To ensure a great experience for everyone, your content is awaiting approval by our Community Managers. Please check back later.

Helpful resources

Quick Links

Responsible AI policies

As AI tools become more common, we’re introducing a Responsible AI Use…

Neeraj Kumar – Community Spotlight

We are honored to recognize Neeraj Kumar as our Community Spotlight honoree for…

Leaderboard > Customer experience | Sales, Customer Insights, CRM

#1
Tom_Gioielli Profile Picture

Tom_Gioielli 72 Super User 2025 Season 2

#2
Daniyal Khaleel Profile Picture

Daniyal Khaleel 32 Most Valuable Professional

#3
Gerardo Rentería García Profile Picture

Gerardo Rentería Ga... 29 Most Valuable Professional

Last 30 days Overall leaderboard

Product updates

Dynamics 365 release plans