SQL Server Error 939 occurs when the database cannot be started because the persistent version of the database is inconsistent with the version expected by the SQL Server engine, often following an interrupted upgrade, a failed patch, or an improper shutdown during a version migration. The fastest way to resolve this is to ensure the SQL Server instance is fully updated to the latest Cumulative Update (CU) or Service Pack (SP) that matches the database's internal version, or to restore the database from a known good backup if the internal version header has become corrupted.

What You'll Need

  • Administrative access to the Windows Server hosting the SQL Server instance.
  • SQL Server Management Studio (SSMS) installed on the server or a remote workstation with connectivity.
  • The installation media or setup files for the specific SQL Server version and Cumulative Update (CU) you are targeting.
  • A full backup of the database (if the error occurred during an upgrade attempt).
  • Access to the SQL Server Error Logs to identify the specific version mismatch.

Step-by-Step

  1. Identify the Version Mismatch: Open SQL Server Management Studio (SSMS) and connect to the instance. If the database is in a "Recovery Pending" or "Suspect" state, you cannot run standard queries against it. Instead, go to the Management folder, expand SQL Server Logs, and open the Current log. Search for "Error 939". The log will typically indicate the version the database expects and the version the engine is currently running. Note these version numbers exactly.
  2. Verify the Current Engine Version: Open a New Query window and execute SELECT @@VERSION;. Compare this output with the version noted in the error log. If the engine version is lower than the database version, you are attempting to attach a database from a newer version of SQL Server to an older instance, which is not supported. If the versions should match but the error persists, the database metadata is likely inconsistent.
  3. Apply Missing Updates: If the engine is behind a specific Cumulative Update that was partially applied to the database, download the corresponding update from the official Microsoft update catalog. Run the installer as an Administrator. Restart the SQL Server service via the SQL Server Configuration Manager to ensure all binaries are correctly loaded. This is the most common fix for Error 939 following a failed Windows Update or SQL Server patching cycle.
  4. Attempt a Manual Database Detach and Attach: If the service is running but the database remains inaccessible, try to detach the database (if possible) or stop the SQL Server service entirely. Navigate to the folder containing the .mdf and .ldf files. Move these files to a temporary backup directory. Restart the service, then attempt to attach the files using the "Attach Database" wizard in SSMS. This forces the engine to re-evaluate the version header during the attachment process.
  5. Force Recovery using EMERGENCY Mode: If the database is stuck and cannot be attached, you may need to put it into EMERGENCY mode to access the data. Execute the following commands in a query window: ALTER DATABASE [YourDatabaseName] SET EMERGENCY; followed by ALTER DATABASE [YourDatabaseName] SET SINGLE_USER;. This allows the administrator to perform consistency checks.
  6. Run DBCC CHECKDB: Once in EMERGENCY mode, run DBCC CHECKDB ([YourDatabaseName]) WITH NO_INFOMSGS, ALL_ERRORMSGS;. Review the output to see if the persistent version error is accompanied by page corruption. If the corruption is limited to the version header, you may be able to repair it, though this is risky.
  7. Restore from Backup: If the version mismatch was caused by a corrupted upgrade process and the steps above fail, the safest path is to drop the corrupted database and restore the most recent full backup. Ensure the target instance is updated to the correct version before initiating the restore to prevent the error from recurring.

Common Mistakes

One of the most frequent mistakes is attempting to "downgrade" a database. SQL Server does not support attaching a database from a newer version (e.g., SQL Server 2022) to an older version (e.g., SQL Server 2019). If you see Error 939 after moving files between servers, double-check that the destination server is not an older build. Another common error is applying a Cumulative Update to the OS but failing to restart the SQL Server service, leaving the engine running on old binaries while the database files expect the new version.

Users also frequently attempt to fix this by deleting the transaction log (.ldf) file. While this can sometimes bypass startup errors, it does not fix a persistent version mismatch and can lead to permanent data loss or a database that remains in a "Suspect" state because the version header resides in the primary data file (.mdf), not the log.

Tips

To prevent this issue in the future, always perform a full backup and a "Tail-Log' backup immediately before applying any SQL Server updates or migrating databases between servers. Use the SQL Server Installation Center to verify that all features and instances are updated uniformly across your environment.

When diagnosing version issues, use the sys.dm_os_sys_info dynamic management view to get detailed build information about the running instance. This provides more granular data than @@VERSION and can help you identify if a specific hotfix is missing that might be causing the version inconsistency.

Troubleshooting

If the database remains inaccessible after applying updates and attempting a restart, check the Windows Event Viewer under "Application" logs. Look for errors originating from MSSQLSERVER. If you see errors related to "Access Denied" or "Cannot open file," the issue may be related to file permissions rather than the persistent version, even if Error 939 was the initial trigger. Ensure the SQL Server Service Account has Full Control permissions over the folder containing the .mdf and .ldf files.

If you are using a mirrored or Always On Availability Group setup, Error 939 can occur if the secondary replica is on a lower build version than the primary. In this case, you must update the secondary replica's SQL Server instance to match the primary exactly before the database can be synchronized and started. If the secondary cannot be brought online, you may need to remove the database from the Availability Group, update the instance, and then re-join it.

Frequently Asked Questions

Can I fix Error 939 without a backup?

Yes, if the cause is a missing Cumulative Update or a service that hasn't been restarted, applying the update and restarting the service will resolve it. If the internal version header is physically corrupted, a backup is usually required for a guaranteed recovery.

Does Error 939 mean my data is lost?

Not necessarily. Error 939 is a metadata mismatch error, meaning the engine refuses to open the file because it doesn't recognize the version. The actual data pages are usually intact, but the "door" to the data is locked due to the version conflict.

Will running DBCC CHECKDB fix the version mismatch?

DBCC CHECKDB identifies corruption; it does not automatically align versions. However, running it in EMERGENCY mode can tell you if the version error is the only problem or if there is deeper structural corruption that requires a restore.

Why did this happen after a Windows Update?

Some Windows Updates include SQL Server patches. If the update process was interrupted or if the server was forced to reboot before the SQL Server binaries were fully updated, the database may have been partially migrated to a new version while the engine remains on the old one.

Is it possible to move a database to an older SQL Server version?

No, SQL Server does not support backward compatibility for database files. You cannot attach a newer version database to an older engine. The only way to move data to an older version is to script the database schema and export the data using BCP or SSIS.