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

Set key in Contact entity column emailaddress1

(0) ShareShare
ReportReport
Posted on by 33

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.

I have the same question (0)
  • Verified answer
    Abdul Wahab Profile Picture
    12,119 Moderator on at

    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

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 83 Super User 2025 Season 2

#2
Gerardo Rentería García Profile Picture

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

#3
#ManoVerse Profile Picture

#ManoVerse 40

Last 30 days Overall leaderboard

Product updates

Dynamics 365 release plans