Wednesday, 1 July 2015

Deleting Microsoft dynamics CRM organization from SQL

Sometimes, we might get the issue when deleting the organizations from on premise CRM.

Here is the procedure to delete Dynamics CRM Organization from Database. 
  • Connect to CRM DB server and right click on CRM organization DB (for example DEMO_MSCRM)
  • Select Delete and make sure to select Close existing connections.

This will delete organization DB , but we also need to remove Organization references from MSCRM_CONFIG DB, so follow below steps.
  • Open SQL Server Management Studio
  • Select MSCRM_CONFIG, right click and select New Query.
  • Execute the below query
            select * from [dbo].Organization
  • Note down ID of the organization which you wanted to delete.
  • Execute the following queries.
           delete from [dbo].[OrganizationFeatureMap] where OrganizationId='ORG_GUID'
           delete from [dbo].SystemUserOrganizations where OrganizationId='ORG_GUID'
           delete from [dbo].[OrganizationProperties] where Id='ORG_GUID'
           delete from dbo.Organization where DatabaseName='ORGNAME_MSCRM'

Note: This is an unsupported method of removing Organization DB and should be used only when not able to delete organization from Deployment Manager for specific reasons.

Hope this helps.
Happy CRM'img

No comments:

Post a Comment