Error Importing Customizations

On a development environment where I had imported a new organization, the developer was getting an error when trying to import customizations from another system (both on Update Rollup 3), and was unable to publish any customizations either. On importing, he got the following error:
“Failure: customeraddress: A SQL Server error occurred. Try this action again. If the problem continues, check the Microsoft Dynamics CRM Community for solutions or contact your organization's Microsoft Dynamics CRM Administrator. Finally, you can contact Microsoft Support.”

In the event log on the server was an error that said:

EventID: 19457
Source: MSCRMWebService
Customization Import failed. Error: Could not find stored procedure 'p_PublishMetadata'.

In digging into the database in SQL Server Management Studio, I saw that this sproc and another called 'p_PublishLabelsByObjectId' were listed not as dbo owned like the rest of the stored procedures, but user owned (DOMAIN\Username.p_PublishMetadata, for example).

I changed the ownership using the following query and publishing and importing started to work:

sp_changeobjectowner 'p_PublishLabelsByObjectId', 'dbo'

and then the same for the other stored procedure:

sp_changeobjectowner 'p_PublishMetadata', 'dbo'

(You'll get a caution about changing ownership that you can ignore.) Close SQL Management Studio and re-open it to verify that the ownership has changed (refreshing didn't work for me for some reason).

Somehow, when this organization was imported, the ownership didn't get set correctly on these two stored procedures. Tip of the hat to Luke Rogers for the tip on changing ownership of stored procedures one at a time.

Environment: SQL Server 2008 Standard, Microsoft CRM 4.0 UR3 Professional with the original organization disabled, and a new organization imported.


ICU MSCRM © 2004-2009