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

ReleaseEngine prefixDefaultSupported levels
SQL Server 202517.0170170, 160, 150, 140, 130, 120, 110, 100
SQL Server 202216.0160160, 150, 140, 130, 120, 110, 100
SQL Server 201915.0150150, 140, 130, 120, 110, 100
SQL Server 201714.0140140, 130, 120, 110, 100
SQL Server 201613.0130130, 120, 110, 100
SQL Server 201412.0120120, 110, 100
SQL Server 201211.0110110, 100, 90
SQL Server 2008 R210.50100100, 90, 80
SQL Server 200810.0100100, 90, 80
SQL Server 20059.09090, 80, 70, 65, 60
SQL Server 20008.08080, 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.

Compare plans and runtime statistics in Query Store

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 DatabaseVersion in 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.

Microsoft reference for database format error 948

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