Wednesday, March 25, 2020

Dynamics CRM - Alternate key fails with message "The statement has been terminated."

If you get the unhelpful message that the "Statement has been terminated.":


Look to see if you have a duplicate value in your key. Unfortunately, if you have more than 50k records, you cannot use fetchXml and either would need to load the data into a database or filter the list by date-range (but the latter option is not guaranteed to catch all the errors and so the db option is your best bet).

Here is a query to find dups based on accountNumber on account entity
 
 
   
   
   
     
   

   
 



It used to be one time that CRM used to throw an error message stating the key creation failed because of a duplicate key. In the latest version, its a rather unhelpful message.


 

No comments: