
SQL Server Database Compatibility Levels and Versions
The default database compatibility level is 170 on SQL Server 2025, 160 on SQL Server 2022, and 150 on SQL Server 2019. Compatibility level is a setting on each database. Check it in sys.databases to see which set of query optimizer and T-SQL behaviors the database uses.
Default and supported compatibility levels by SQL Server version
| Release | Engine prefix | Default | Supported levels |
|---|---|---|---|
| SQL Server 2025 | 17.0 | 170 | 170, 160, 150, 140, 130, 120, 110, 100 |
| SQL Server 2022 | 16.0 | 160 | 160, 150, 140, 130, 120, 110, 100 |
| SQL Server 2019 | 15.0 | 150 | 150, 140, 130, 120, 110, 100 |
| SQL Server 2017 | 14.0 | 140 | 140, 130, 120, 110, 100 |
| SQL Server 2016 | 13.0 | 130 | 130, 120, 110, 100 |
| SQL Server 2014 | 12.0 | 120 | 120, 110, 100 |
| SQL Server 2012 | 11.0 | 110 | 110, 100, 90 |
| SQL Server 2008 R2 | 10.50 | 100 | 100, 90, 80 |
| SQL Server 2008 | 10.0 | 100 | 100, 90, 80 |
| SQL Server 2005 | 9.0 | 90 | 90, 80, 70, 65, 60 |
| SQL Server 2000 | 8.0 | 80 | 80, 70, 65, 60 |
SQL Server 2022 supports levels 100 through 160 in increments of ten. If you restore a SQL Server 2019 database at level 150 onto SQL Server 2022, the database can stay at 150. A level below the destination’s minimum is raised to the minimum. New databases normally use the engine default, which can also be affected by the model database.
Microsoft compatibility level referenceMicrosoft’s historical SQL Server 2005 level valuesSQL Server 2000 setup documentation
Check a database’s compatibility level in T-SQL
SELECT name, compatibility_level
FROM sys.databases
ORDER BY name;In SSMS, right-click the database and open Properties → Options → Compatibility level. In the same instance, databases can use different levels.
Change the SQL Server database compatibility level
This example sets a database named Example to level 160. Use a database you can change and a level supported by its engine.
ALTER DATABASE [Example]
SET COMPATIBILITY_LEVEL = 160;Capture representative query performance before and after the change. Query Store can show changes in plans and runtime statistics. Record the previous compatibility level so you can restore the setting if it is supported and the application needs it.
Engine build vs. compatibility level vs. database version
- Engine build
- The installed SQL Server version, such as
16.0.4135.4. Use it to identify the patch and KB. - Compatibility level
- A database setting such as
150. It selects certain optimizer and T-SQL behaviors on the running engine. - Internal database version
- The storage format. Read
DatabaseVersionin a backup header to investigate a restore or attach failure.
SQL Server internal database format versions
These values are documented in engine logs and restore examples. Previews and some older service packs can use different formats. Check the backup header and test the restore on the exact destination build.
Check SQL Server backup compatibility before restoring
Run RESTORE HEADERONLY from an instance whose SQL Server service can read the file. The query returns one row per backup set. Use the database name, backup date, and position to find the relevant set.
RESTORE HEADERONLY
FROM DISK = N'D:\SQLBackups\Example.bak';DatabaseVersion identifies the database format and CompatibilityLevel records the database setting. SoftwareVersionMajor, SoftwareVersionMinor, and SoftwareVersionBuild identify the engine software that wrote the backup.
A backup taken on SQL Server 2022 at compatibility level 150 still needs a destination that can restore a SQL Server 2022 backup. For example, SQL Server 2019 rejects the newer format even though it supports level 150. For an upgrade rollback, keep a backup taken on the original engine and test it before cutover.
Microsoft backup header referencePlan an engine upgradeIdentify the installed build
