| 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 |
|
||
| helpviewer_keywords |
|
||
| dev_langs |
|
[!INCLUDE SQL Server]
Sets certain database behaviors to be compatible with the specified version of [!INCLUDE ssNoVersion].
Important
[!INCLUDE ssNoteDepFutureAvoid] Use ALTER DATABASE (Transact-SQL) compatibility level instead.
:::image type="icon" source="../../includes/media/topic-link-icon.svg" border="false"::: Transact-SQL syntax conventions
sp_dbcmptlevel
[ [ @dbname = ] N'dbname' ]
[ , [ @new_cmptlevel = ] new_cmptlevel OUTPUT ]
[ ; ]
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.
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:
90= [!INCLUDE ssVersion2005]100= [!INCLUDE sql2008-md]110= [!INCLUDE ssSQL11]120= [!INCLUDE ssSQL14]130= [!INCLUDE sssql16-md]140= [!INCLUDE sssql17-md]150= [!INCLUDE sssql19-md]160= [!INCLUDE sssql22-md]
0 (success) or 1 (failure).
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.
For a description of compatibilities levels, see ALTER DATABASE (Transact-SQL) compatibility level.
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.