Check and change the compatibility level of the database in the SQL Server
Check the compatibility level for the Database
SELECT compatibility_level FROM sys.databases WHERE name ='AdventureWorks2019';
Check the compatibility level for all the databases:
SELECT name,compatibility_level FROM sys.databases
name compatibility_level
master 140
tempdb 140
model 140
msdb 140
TEST 140
AdventureWorks2017 140
AdventureWorks2022 140
TESTNEW 140
Project 140
Change the compatibility level as :
ALTER DATABASE TESTNEW SET COMPATIBILITY_LEVEL = 130;
Chart of compatibility level:
Product | Default Compatibility Level | Supported Compatibility Level |
SQL Server 2019 (15.x) | 150 | 150, 140, 130, 120, 110, 100 |
SQL Server 2017 (14.x) | 140 | 140, 130, 120, 110, 100 |
SQL Server 2016 (13.x) | 130 | 130, 120, 110, 100 |
SQL Server 2014 (12.x) | 120 | 120, 110, 100 |
SQL Server 2012 (11.x) | 110 | 110, 100, 90 |
SQL Server 2008 R2 | 100 | 100, 90, 80 |
Azure SQL Database | 150 | 150, 140, 130, 120, 110, 100 |