Skip to content

Latest commit

 

History

History
81 lines (58 loc) · 3.38 KB

File metadata and controls

81 lines (58 loc) · 3.38 KB
title sp_dbcmptlevel (Transact-SQL)
description sp_dbcmptlevel sets certain database behaviors to be compatible with the specified version of SQL Server.
author markingmyname
ms.author maghan
ms.reviewer randolphwest
ms.date 06/23/2025
ms.service sql
ms.subservice system-objects
ms.topic reference
f1_keywords
sp_dbcmptlevel
sp_dbcmptlevel_TSQL
helpviewer_keywords
sp_dbcmptlevel
dev_langs
TSQL

sp_dbcmptlevel (Transact-SQL)

[!INCLUDE SQL Server]

Sets certain database behaviors to be compatible with the specified version of [!INCLUDE ssNoVersion].

:::image type="icon" source="../../includes/media/topic-link-icon.svg" border="false"::: Transact-SQL syntax conventions

Syntax

sp_dbcmptlevel
    [ [ @dbname = ] N'dbname' ]
    [ , [ @new_cmptlevel = ] new_cmptlevel OUTPUT ]
[ ; ]

Arguments

[ @dbname = ] N'dbname'

The name of the database for which the compatibility level is to be changed. Database names must conform to the rules for identifiers. @dbname is sysname, with a default of NULL.

[ @new_cmptlevel = ] new_cmptlevel OUTPUT

The version of [!INCLUDE ssNoVersion] with which the database is to be made compatible. @new_cmptlevel is an OUTPUT parameter of type tinyint, and must be one of the following values:

Return code values

0 (success) or 1 (failure).

Result set

If no parameters are specified or if the @dbname parameter isn't specified, sp_dbcmptlevel returns an error.

If @dbname is specified without @new_cmptlevel, the [!INCLUDE ssDE] returns a message displaying the current compatibility level of the specified database.

Remarks

For a description of compatibilities levels, see ALTER DATABASE (Transact-SQL) compatibility level.

Permissions

Only the database owner, members of the sysadmin fixed server role, and the db_owner fixed database role (if you're changing the current database) can execute this procedure.

Related content