Unknown SQL Error in ConfigMgr Logs

While working an issue for one of my clients recently, I ran into errors like the following in the policypv.log and the wsyncmgr.log:

Policypv.log

*** *** Unknown SQL Error! in ConfigMgr Logs

CDeviceEnrollmentGenericSCConfig::GenerateDevicePolicyXML: failed to retrieve DTGuid from AppModelname 0

 

wsyncmgr.log

*** *** Unknown SQL Error!

Failed to sync update 15441c35-cd5f-4ea9-b067-7f50c7649e4f. Error: Failed to save update b9afe9e1-5b8d-44cf-b362-0c7dd84c955c. CCISource error: -1. Source:

The WSUS synchronization was also failing.

After some investigating, I discovered that the SA account was not the owner of the ConfigMgr database. The TRUSTWORTHY option was also set to FALSE. This indicated to me that the DB was moved at some point. Probably to a new disk.

To resolve the issue I performed the following:

Check the DB ownership with the following SQL stored procedure:

EXEC sp_helpdb

If the SA account does not own the ConfigMgr DB, error will be generated and ConfigMgr will not work properly.

I then changed the DB owner to SA via the following SQL:

USE <Database Name Here>
GO
EXEC sp_changedbowner 'sa'

I then checked if the TRUSTWORTHY option was set to TRUE.

To check this option, open up SQL Management Studio, right-click on the ConfigMgr DB (should be named like CM_XXX) and then click on Properties. Once in the properties window, click on Options on the left side of the window. Then scroll down in the properties window until you see the TRUSTWORTHY option and it’s current value.

I discovered that TRUSTWORTHY was set to FALSE, so I used to following SQL to set it to TRUE:

ALTER DATABASE <Database Name Here> SET TRUSTWORTHY ON

After making these changes, Software Updates began syncing successfully and the policypv.log reported that it was now successfully processing policy.