Skip to main content

Notifications

Community site session details

Community site session details

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

Set key in Contact entity column emailaddress1

(0) ShareShare
ReportReport
Posted on by 31

Hi everyone,

I'm tring to set emailaddress1 as key in my Contact entity. 

Previously I check and clean the column and there are no duplicate data.

I can't understand why, setting this field as key, the system job doesn't work.

On log I can see this error: 

The CREATE UNIQUE INDEX statement terminated because a duplicate key was found for the object name 'dbo.ContactBase' and the index name 'ndx_for_entitykey_new_KEY_emailaddress1'. The duplicate key value is <redacted>.

AND

System.ServiceModel.FaultException`1[Microsoft.Xrm.Sdk.OrganizationServiceFault]: Sql error: Generic SQL error. CRM ErrorCode: -2147204784 Sql ErrorCode: -2146232060 Sql Number: 1505 (Fault Detail is equal to Exception details:
ErrorCode: 0x80044150
Message: Sql error: Generic SQL error. CRM ErrorCode: -2147204784 Sql ErrorCode: -2146232060 Sql Number: 1505
TimeStamp: 2023-05-11T16:11:08.9014027Z
--
Exception details:
ErrorCode: 0x80040216
Message: Exception output:: System.Data.SqlClient.SqlException (0x80131904): The CREATE UNIQUE INDEX statement terminated because a duplicate key was found for the object name 'dbo.ContactBase' and the index name 'ndx_for_entitykey_new_KEY_emailaddress1'. The duplicate key value is <redacted>.
at Microsoft.Crm.CrmDbConnection.HandleExecutionExceptionAbstract(Exception exception, String commandText, IDbConnection connection, IDbCommand command, IDbTransaction transaction, Boolean isOpen, Int32 commandTimeout, IConnectionRetryPolicy localRetryPolicy, Int32& retryCount)
at Microsoft.Crm.CrmDbConnection.InternalExecuteWithRetryAbstract[TResult](Func`1 executeMethod, IDbCommand command, IConnectionRetryPolicy retryPolicy)
at Microsoft.Crm.CrmDbConnection.<>c_...).

Can anyone help me?

Thanks in advance

S.I.

  • Verified answer
    Abdul Wahab Profile Picture
    12,085 Moderator on at
    RE: Set key in Contact entity column emailaddress1

    Hi Silvia Innamorati

    Use SQL, for CDS in XRM tool-box. Run the below similar query, that will return the number of records that are still duplicates.

    SELECT emailaddress1  AS emailaddress,
    count(fullname) AS count
    FROM contact
    GROUP BY emailaddress1
    Order BY count DESC

    Fix these records. Now you are able to create a new key for emailaddress1  

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

🌸 Community Spring Festival 2025 Challenge 🌸

WIN Power Platform Community Conference 2025 tickets!

Jonas ”Jones” Melgaard – Community Spotlight

We are honored to recognize Jonas "Jones" Melgaard as our April 2025…

Kudos to the March Top 10 Community Stars!

Thanks for all your good work in the Community!

Leaderboard

#1
André Arnaud de Calavon Profile Picture

André Arnaud de Cal... 294,206 Super User 2025 Season 1

#2
Martin Dráb Profile Picture

Martin Dráb 232,968 Most Valuable Professional

#3
nmaenpaa Profile Picture

nmaenpaa 101,158 Moderator

Leaderboard

Featured topics

Product updates

Dynamics 365 release plans