Microsoft KB Archive/921391

= Error message when you delete a record in Microsoft Dynamics CRM: &quot;Error: Deletion Service failed to clean up some tables&quot; =

Article ID: 921391

Article Last Modified on 11/19/2007

-

APPLIES TO


 * Microsoft Dynamics CRM 3.0

-



SYMPTOMS
When you delete a record in Microsoft Dynamics CRM, the following error message may be logged in the Application log:

Event Type: Error

Event Source: MSCRMDeletionService

Event Category: None

Event ID: 16387

Date:

Time:

AM User: N/A

Computer:

Description:

Error: Deletion Service failed to clean up some tables.



CAUSE
This problem occurs because there is a constraint on the entity table of the record that is being deleted. Additionally, the user who deletes the record may not have the rights to delete all the associated records.

For example, assume that you have rights to delete only contacts. You try to delete a contact that is associated with three cases. In Microsoft Dynamics CRM, the cascade relationship between the contact entity and the case entity is set to &quot;Cascade Delete All.&quot; Therefore, the contact record is set to a delete status in the Microsoft Dynamics CRM database. However, you do not have rights to delete cases. Therefore, the delete status is not set on the case records. When the Deletion Service tries to delete the contact record, a constraint blocks that deletion because there are three existing cases that are assigned to the contact. To successfully delete this record, you must delete the records that cause the constraint conflict.



RESOLUTION
To resolve this problem, follow these steps.

Note Before you follow the instructions in this article, make sure that you have a complete backup copy of the database that you can restore if a problem occurs.

To identify the table where the Deletion Service is failing, follow these steps:  On the Microsoft Dynamics CRM server, click Start, click Run, type cmd, and then click OK. At the command prompt, type crmdeletionservice.exe –runonce, and then press ENTER.

Note By default, the Crmdeletionservice.exe file is located in the : \program files\Microsoft Dynamics CRM\server\bin directory.

Then, you receive a message that resembles the following message:

Can't clean up the following tables: Campaign

Note The table that is returned in the message is the table for which the Deletion Service failed.

The following example demonstrates how to resolve this problem for the Campaign table.

To resolve the problem for the Campaign table, follow these steps:  Run a statement in SQL Query Analyzer. To do this, follow these steps:  Click Start, point to All Programs, point to Microsoft SQL Server, and then click Query Analyzer.  Run the following query against the _MSCRM database.

Note  is a placeholder for the actual organization name. delete from Campaign where DeletionStateCode = 2 This query returns a message that resembles the following message:

DELETE statement conflicted with COLUMN REFERENCE constraint 'campaign_leads'. The conflict occurred in database ' _MSCRM', table 'LeadBase', column 'CampaignId'. The statement has been terminated.

</ol> </li>  Correct the records that are causing the constraint conflict by using a statement that resembles the following statement. Update LeadBase set CampaignId=null WHERE CampaignId IN (SELECT CampaignId FROM CampaignBase WHERE DeletionStateCode = 2) Note The table and the fields that you use in the statement depend on the message that you received in step 1b earlier in this section. In this example, you are setting the CampaignId field in the LeadBase table to null if the campaign has been marked for deletion. </li>  Run the following command to verify that all the tables have been corrected. crmdeletionservice.exe –runonce If you still experience a problem, repeat steps 1 through 3 earlier in this section to correct the other constraints. </li></ol>

Keywords: kbmbscrm40no kbtshoot kberrmsg kbmbsmigrate kbprb KB921391

-

[mailto:TECHNET@MICROSOFT.COM Send feedback to Microsoft]

© Microsoft Corporation. All rights reserved.