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.
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
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