Upgraded database schema doesn’t match targetschema

Databases in upgrade mode after patching a SharePoint 2016 server

If you get an upgrade error after having patched a SharePoint 2016 server farm: "Database is in compatibility range and upgrade is recommended". You will see this if you open Central Administration, click on "Upgrade and migration" and on "Review Database Status":

Then first run the SharePoint Configuration Wizard and see if that fixes the error. If that ends with a "Failed to upgrade" message, then perform the steps listed below to fix the problem:

"Failed to upgrade SharePoint Products

An exception of type Microsoft.SharePoint.PostSetupConfiguration.PostSetupConfigurationTaskException was thrown.  Additional exception information:

Upgrade [SPContentDatabase Name=WSS_Content_47xxxxxxxxxxxxxxxxx...] failed. (EventID:an59t)

Exception: The upgraded database schema doesn't match the TargetSchema (EventID:an59t)

Upgrade Timer job is exiting due to exception: Microsoft.SharePoint.Upgrade.SPUpgradeException: The upgraded database schema doesn't match the TargetSchema"

Steps to fix the upgrade error

Start the SharePoint 2016 Management Shell. Note: you might have to be logged in as a farm admin to do this.

Run the following command:

Get-SPContentDatabase | ?{$_.NeedsUpgrade –eq $true} | Upgrade-SPContentDatabase -Confirm:$false

Then restart the upgrade using this command:

psconfig.exe -cmd upgrade -inplace b2b

This will trigger an upgrade of the databases that was incomplete.

If all goes well you should see this:

Now go back again to "Upgrade and migration" and "Database status". The databases should have status "No action required":

5 9 votes
Rate this article!
Subscribe
Notify of
guest

This site uses Akismet to reduce spam. Learn how your comment data is processed.

5 Comments
newest
oldest most voted
Inline Feedbacks
View all comments
nasran

Thank you so much. This post has saved me.

Raghu

It’s good Article very useful I glad to thank you my issue got resolved

Alexander

Legend, thank you 🙂