COMPATIBILITY_LEVEL
Which version's query optimizer and T-SQL behavior a database uses.
- Predeterminado
170- Range
- 100 to 170 on SQL Server 2025
- Restart needed
- No
- Default checked on
- SQL Server 2025
Lo que hace
Controls cardinality estimator version and Intelligent Query Processing features such as batch mode on rowstore (150+) and parameter-sensitive plan optimization (160+). New databases copy model's level.
Valor predeterminado
170. 170 for new databases on SQL Server 2025 (160 on 2022, 150 on 2019). An upgraded or restored database keeps its old level.
Check the current value
SELECT name, compatibility_level FROM sys.databases WHERE name = DB_NAME();
Change it
ALTER DATABASE CURRENT SET COMPATIBILITY_LEVEL = 170;
No restart; applies to plans compiled after the change.
When to change it
After an upgrade, raise it once Query Store has a baseline under the old level, so you can force old plans for any query that regresses.
What can go wrong
Plan changes for many queries at once; test with Query Store capturing first.
Questions about COMPATIBILITY_LEVEL
What is the default value of COMPATIBILITY_LEVEL in SQL Server?
170. 170 for new databases on SQL Server 2025 (160 on 2022, 150 on 2019). An upgraded or restored database keeps its old level.
Does changing COMPATIBILITY_LEVEL require a restart?
No. No restart; applies to plans compiled after the change.
When should I change COMPATIBILITY_LEVEL?
After an upgrade, raise it once Query Store has a baseline under the old level, so you can force old plans for any query that regresses.
Back to all SQL Server settings, or check the SQL Server manual for every option.
Check COMPATIBILITY_LEVEL on your own server
SQLly runs the query above against SQL Server and the other engines in this reference, from one desktop app on macOS, Windows and Linux.