SQL Server Error 937 occurs when you attempt to attach or upgrade a database from an older version of SQL Server to a newer one, but the database is in a state that prevents the upgrade process from completing. Specifically, the error message "Database cannot be upgraded because functionality is not supported" usually triggers when the database was not shut down cleanly or contains features—such as certain types of mirroring, availability groups, or specific snapshot configurations—that are incompatible with the target version's upgrade path. To resolve this, you must ensure the database is in a consistent, clean state and that all blocking functionality is disabled before attempting the upgrade again.
What You'll Need
- Administrative access to the SQL Server instance (sysadmin role).
- SQL Server Management Studio (SSMS) installed and connected to the instance.
- A full, verified backup of the database before attempting any recovery or state changes.
- Knowledge of the source SQL Server version and the target version you are upgrading to.
Step-by-Step
- Perform a Full Backup: Before executing any commands to change the state of your database, right-click the database in SSMS, select Tasks > Back Up, and create a full backup. This ensures that if a recovery attempt fails, you can return to the original state.
- Identify the Blocking Functionality: Error 937 is often a generic wrapper. Check the SQL Server Error Log (Management > SQL Server Logs) to see if there are accompanying messages. Look for mentions of "Mirroring," "Availability Groups," or "Database Snapshots." If the database was part of a mirroring partnership, the upgrade will fail because the target server cannot negotiate the partnership during the upgrade phase.
- Remove Mirroring or Availability Group Membership: If the database is part of a mirrored pair, you must break the mirror. Run the command
ALTER DATABASE [YourDatabaseName] SET PARTNER OFF;. If it is part of an Availability Group, remove the database from the group on both the primary and secondary replicas. The database must be a standalone entity before the upgrade process can transition the internal versioning. - Ensure a Clean Shutdown: The upgrade process requires the database to be in a "Clean" state. If the database was detached while the server was crashing or if the files were simply copied from another server without a proper detach or backup, the internal flags may indicate the database is "dirty." The most reliable way to fix this is to restore the database from a full backup onto the new server rather than attaching the .mdf and .ldf files manually.
- Detach and Re-attach (If not using Backups): If you must use the attach method, ensure the source server has fully detached the database. On the source server, right-click the database > Tasks > Detach. Ensure "Drop Connections" is checked. Then, move the files to the new server and use the Attach Database task in SSMS.
- Check for Database Snapshots: If you have created database snapshots of the source database, these can sometimes interfere with the upgrade metadata. Drop any existing snapshots associated with the database on the source server before moving the database to the new version.
- Execute the Upgrade: Once the blocking functionality is removed and the database is detached cleanly, attach it to the new instance. SQL Server will automatically begin the upgrade process. You can monitor the progress by running
SELECT name, state_desc FROM sys.databases;. The state should transition from RESTORING or RECOVERING to ONLINE. - Update Statistics: After a successful upgrade from an older version, the query optimizer may struggle with outdated statistics. Run
EXEC sp_updatestats;on the upgraded database to ensure performance remains stable.
Common Mistakes
One of the most frequent mistakes is attempting to "force" the attach process by ignoring warnings about the database state. Many users try to copy the .mdf and .ldf files while the SQL Server service is still running on the source machine. This leads to a "dirty" shutdown state, which is a primary trigger for Error 937. Always stop the SQL service or use the official Detach command to ensure the transaction log is truncated and the database is marked as clean.
Another common error is forgetting to handle the transaction logs. If you only copy the primary data file (.mdf) and attempt to attach it without the log file (.ldf), SQL Server will try to rebuild the log. If the database was not shut down cleanly, this rebuild process will fail during the upgrade, resulting in the functionality error. Always move both the data and log files together.
Users also frequently overlook the version gap. While SQL Server generally supports upgrading across a few versions (e.g., 2014 to 2019), attempting to jump too many versions at once can occasionally trigger unexpected functionality errors. In such cases, upgrading to an intermediate version first can resolve the issue.
Tips
Whenever possible, use the Backup and Restore method instead of the Detach and Attach method. Restore is the industry standard for upgrades because it handles the internal state transitions more gracefully and ensures that the database is recovered to a consistent point in time. It also allows you to keep the source database online while you test the upgrade on the target server.
Check the compatibility level after the upgrade. Even though the database has been upgraded to the new version of SQL Server, the compatibility_level setting often remains at the old version's value. To take advantage of new query optimizer features, right-click the database > Properties > Options and update the Compatibility level to the latest version supported by your instance.
Keep an eye on the sys.databases view during the process. If the database stays in a "RECOVERING" state for an unusually long time, check the Error Log to see if it is performing a large undo/redo operation on the transaction log, which is common for databases with many open transactions at the time of detachment.
Troubleshooting
If the error persists after removing mirroring and ensuring a clean shutdown, try the following steps in order:
1. Check for Orphaned Files: Ensure there are no leftover .ndf (secondary data) files from the source server that were missed during the file transfer. If the database expects a file that is missing, the upgrade process may throw a generic functionality error.
2. Verify Disk Permissions: Ensure the SQL Server Service Account on the new machine has full "Full Control" permissions over the folder where the .mdf and .ldf files are located. If the service cannot write to the log file during the upgrade, it may report a functionality failure.
3. Use Emergency Mode: If the database is corrupted and won't attach, you can try setting it to EMERGENCY mode. Run ALTER DATABASE [YourDatabaseName] SET EMERGENCY; followed by DBCC CHECKDB ([YourDatabaseName], REPAIR_ALLOW_DATA_LOSS);. Warning: This is a last resort and can result in data loss. Only do this if you have a backup and the standard upgrade path is completely blocked.
4. Check for Third-Party Encryption: If the database was encrypted using a third-party tool or a specific version of Transparent Data Encryption (TDE), you must migrate the Service Master Key and the Certificate to the new server before the database can be upgraded. Without the keys, the upgrade process cannot read the encrypted pages and will fail.
Frequently Asked Questions
Can I fix Error 937 without a backup?
It is possible if you have the original .mdf and .ldf files and can access the source server to perform a proper detach. However, it is extremely risky; any failure during the recovery process could lead to permanent data loss.
Does this error happen during a Windows update?
No, Error 937 is specific to the SQL Server database engine and occurs during the attachment or restoration of a database from a different version of SQL Server.
Will upgrading the compatibility level fix Error 937?
No. The compatibility level is changed after the database is successfully upgraded. Error 937 prevents the database from reaching the ONLINE state, meaning you cannot change the compatibility level until the error is resolved.
Is this error related to the SQL Server Edition (Express vs Enterprise)?
Generally, no. However, if you are moving a database from Enterprise Edition to Express Edition, you may encounter errors if the database uses Enterprise-only features (like compression or partitioning). This is a separate issue from Error 937, though both occur during the upgrade/attach phase.
How long does the upgrade process usually take?
The time varies based on the size of the database and the volume of the transaction log. Small databases upgrade in seconds, while multi-terabyte databases may take hours to transition through the recovery phase.