“Database upgrade failed” – Issues with upgrading the content database during the SharePoint upgrade.

Loading

Database Upgrade Failed – Troubleshooting SharePoint Content Database Upgrade Issues

When upgrading SharePoint, you might encounter database upgrade failures, preventing the migration of content databases from an older version to the new SharePoint environment. These failures often result from incompatible database schema, missing service applications, corrupt data, or insufficient permissions. Below is a detailed step-by-step guide to diagnosing and resolving database upgrade issues in SharePoint.


Step 1: Understand the Type of Database Upgrade

Before troubleshooting, identify your database upgrade scenario:

  • SharePoint 2013 → SharePoint 2016
  • SharePoint 2016 → SharePoint 2019
  • SharePoint 2019 → SharePoint Subscription Edition
  • SharePoint On-Premises → SharePoint Online (Hybrid Migration)

Each version has different requirements and upgrade steps.


Step 2: Ensure Prerequisites Are Met

  1. Backup the SharePoint Databases
    • Use SQL Server Management Studio (SSMS) to back up the content database: BACKUP DATABASE [WSS_Content] TO DISK = 'C:\Backup\WSS_Content.bak'
    • Always test the backup restoration before proceeding.
  2. Check Database Compatibility
    • Ensure the SQL Server version supports the target SharePoint version.
    • Run the following command in SQL Server to check the compatibility level: SELECT compatibility_level FROM sys.databases WHERE name = 'WSS_Content'
    • Upgrade the compatibility level if necessary: ALTER DATABASE [WSS_Content] SET COMPATIBILITY_LEVEL = 130 (Replace 130 with the required level for your SharePoint version.)

Step 3: Verify SharePoint Server and SQL Server Connectivity

  1. Ensure SQL Server is running and accessible from the SharePoint server.
  2. Check SQL Server Permissions:
    • The SharePoint Farm Account should have db_owner permissions on the database: USE [WSS_Content] EXEC sp_addrolemember N'db_owner', N'SP_FarmAccount'
    • Ensure dbcreator and securityadmin roles are assigned to the SharePoint Setup Account.

Step 4: Attach the Content Database in SharePoint

If the upgrade fails, manually attach the database:

  1. Open SharePoint Management Shell as Administrator.
  2. Run the following command to detach any existing failed upgrade: Dismount-SPContentDatabase -Identity "WSS_Content"
  3. Reattach the database and upgrade it: Mount-SPContentDatabase -Name "WSS_Content" -DatabaseServer "SQLServerName" -WebApplication "http://yourwebapp"
  4. If errors occur, note the error messages for further troubleshooting.

Step 5: Run the SharePoint Upgrade Commands

Run the upgrade check before applying the upgrade:

Test-SPContentDatabase -Name "WSS_Content" -WebApplication "http://yourwebapp"
  • This command validates missing site collections, orphaned objects, and schema inconsistencies.
  • Resolve any issues flagged in the report.

Run the actual upgrade command:

Upgrade-SPContentDatabase -Identity "WSS_Content"

Monitor logs for errors.


Step 6: Check ULS Logs and SQL Server Logs for Errors

  • SharePoint ULS Logs:
    • Location: C:\Program Files\Common Files\Microsoft Shared\Web Server Extensions\16\LOGS\
    • Look for keywords like “Upgrade failed”, “SQL error”, or “Schema mismatch”.
  • SQL Server Logs:
    • Open SQL Server Management Studio → Management → SQL Server Logs.

Step 7: Resolve Common Errors

1. Missing Site Collections or Web Applications

  • If the upgrade fails due to missing sites, restore them using: Restore-SPSite -Identity http://yoursite -Path C:\Backup\SiteBackup.bak
  • If the web application is missing, recreate it in SharePoint Central Admin.

2. Database Schema Mismatch

  • If SharePoint reports schema version mismatches, run: Get-SPContentDatabase | Select Name, NeedsUpgrade, SchemaVersion
  • If NeedsUpgrade is True, manually upgrade: Upgrade-SPContentDatabase -Identity "WSS_Content"

3. Orphaned Features or Solutions

  • Run the following command to detect orphaned features: Get-SPFeature | Where-Object { $_.Scope -eq "WebApplication" -and $_.Id -eq "GUID_of_Feature" }
  • Remove orphaned features using: Disable-SPFeature -Identity "FeatureName" -Confirm:$false

4. Large Database Causing Timeout Issues

  • If the content database is too large, split it into multiple site collections before upgrading.
  • Increase the SQL Server timeout setting: EXEC sp_configure 'remote query timeout', 600; RECONFIGURE;

Step 8: Final Upgrade Validation

After a successful upgrade:

  1. Verify Site Functionality:
    • Browse key sites and test document libraries, workflows, and custom solutions.
  2. Check SharePoint Health Analyzer:
    • Go to Central Admin → Monitoring → Health Analyzer and resolve any warnings.
  3. Run Full Crawl in Search Service: Start-SPEnterpriseSearchFullCrawl -SearchApplication "Search Service Application"
  4. Test User Access & Permissions:
    • Ensure that users can access content without permission issues.

Step 9: Backup and Document the Upgrade

After the successful upgrade:

  • Take a final backup of the upgraded database.
  • Document any custom fixes applied.
  • Monitor performance logs for a few days.

Final Recommendations

Always perform a test upgrade in a non-production environment first.
Ensure SQL Server and SharePoint versions are compatible before upgrading.
Monitor ULS logs and SQL error logs throughout the process.
Run health checks after the upgrade to prevent post-upgrade issues.

By following these steps, you can troubleshoot and fix SharePoint database upgrade failures efficiently.

Leave a Reply

Your email address will not be published. Required fields are marked *