Skip to content

Latest commit

 

History

History
85 lines (58 loc) · 4.12 KB

File metadata and controls

85 lines (58 loc) · 4.12 KB
title View or change the compatibility level of a database
description Learn how to view or change the compatibility level of a database in SQL Server or Azure SQL by using SQL Server Management Studio or Transact-SQL.
author WilliamDAssafMSFT
ms.author wiassaf
ms.date 2/2/2022
ms.service sql
ms.subservice supportability
ms.topic conceptual
helpviewer_keywords
compatibility levels [SQL Server], viewing
compatibility [SQL Server], databases
compatibility levels [SQL Server], changing
monikerRange =azuresqldb-current||>=sql-server-2016||>=sql-server-linux-2017||=azuresqldb-mi-current

View or change the compatibility level of a database

[!INCLUDE SQL Server Azure SQL Database Azure SQL Managed Instance] This article describes how to view or change the compatibility level of a database in [!INCLUDEssnoversion], Azure SQL Database, or Azure SQL Managed Instance by using [!INCLUDEssManStudioFull] or [!INCLUDEtsql].

Important

Before you change the compatibility level of a database, you should understand the impact of the change on your applications. For more information, see ALTER DATABASE Compatibility Level (Transact-SQL).

Permissions

Requires ALTER permission on the database.

Use SQL Server Management Studio

To view or change the compatibility level of a database using SQL Server Management Studio (SSMS)

  1. Connect to the appropriate server or instance hosting your database.

  2. Select the server name in Object Explorer.

  3. Expand Databases, and, depending on the database, either select a user database or expand System Databases and select a system database.

Note

You cannot modify the compatibility level of system databases in Azure SQL Database.

  1. Right-click the database, and then select Properties.

    The Database Properties dialog box opens.

  2. In the Select a page pane, select Options.

  3. The current compatibility level is displayed in the Compatibility level list box.

    To change the compatibility level, select a different option from the list. The available options for different [!INCLUDEssDE-md] versions are listed in the ALTER DATABASE Compatibility Level (Transact-SQL) page.

Use Transact-SQL

You can use Transact-SQL to view or change the compatibility level of a database using SSMS or Azure Data Studio.

View the compatibility level of a database

  1. Connect to the appropriate server or instance hosting your database.

  2. Open a New Query.

  3. Copy and paste the following example into the query window and select Execute. This example returns the compatibility level of the AdventureWorks2019 sample database.

USE AdventureWorks2019;  
GO  
SELECT compatibility_level  
FROM sys.databases WHERE name = 'AdventureWorks2019';  
GO  

Change the compatibility level of a database

  1. Connect to the appropriate server or instance hosting your database.

  2. From the Standard bar, select New Query.

  3. Copy and paste the following example into the query window and select Execute. This example changes the compatibility level of the AdventureWorks2019 database to 150, which is the compatibility level for [!INCLUDEssSQL19].

ALTER DATABASE AdventureWorks2019  
SET COMPATIBILITY_LEVEL = 150;  
GO

Next steps