参考资料
语法 #
ALTER DATABASE database_name
SET COMPATIBILITY_LEVEL = { 150 | 140 | 130 | 120 | 110 | 100 | 90 }
Arguments #
database_name Is the name of the database to be modified.
COMPATIBILITY_LEVEL { 150 | 140 | 130 | 120 | 110 | 100 | 90 | 80 } Is the version of SQL Server with which the database is to be made compatible. The following compatibility level values can be configured (not all versions supports all of the above listed compatibility level):
Product | Database Engine Version | Default Compatibility Level Designation | Supported Compatibility Level Values |
---|
Product | Database Engine Version | Default Compatibility Level Designation | Supported Compatibility Level Values |
---|---|---|---|
SQL Server 2019 (15.x) | 15 | 150 | 150, 140, 130, 120, 110, 100 |
SQL Server 2017 (14.x) | 14 | 140 | 140, 130, 120, 110, 100 |
Azure SQL Database | 12 | 150 | 150, 140, 130, 120, 110, 100 |
Azure SQL Database Managed Instance | 12 | 150 | 150, 140, 130, 120, 110, 100 |
SQL Server 2016 (13.x) | 13 | 130 | 130, 120, 110, 100 |
SQL Server 2014 (12.x) | 12 | 120 | 120, 110, 100 |
SQL Server 2012 (11.x) | 11 | 110 | 110, 100, 90 |
SQL Server 2008 R2 | 10.5 | 100 | 100, 90, 80 |
SQL Server 2008 | 10 | 100 | 100, 90, 80 |
SQL Server 2005 (9.x) | 9 | 90 | 90, 80 |
SQL Server 2000 (8.x) | 8 | 80 | 80 |
For example, database compatibility level 130 was the default in SQL Server 2016 (13.x). Because compatibility levels force specific Transact-SQL functional and query optimization behaviors, a database certified to work on SQL Server 2016 (13.x) was implicitly certified on database compatibility level 130. This database can work as-is on a more recent version of SQL Server (such as SQL Server 2019 (15.x)) and Azure SQL Database, as long as the database compatibility level is kept as 130.Add label