sp_dbcmptlevel (Transact-SQL)

Applies to: SQL Server

Sets certain database behaviors to be compatible with the specified version of SQL Server.

Important

This feature will be removed in a future version of SQL Server. Avoid using this feature in new development work, and plan to modify applications that currently use this feature. Use ALTER DATABASE Compatibility Levelinstead.

Transact-SQL syntax conventions

Syntax

  
sp_dbcmptlevel [ [ @dbname = ] name ]   
    [ , [ @new_cmptlevel = ] version ]  

Arguments

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

[ @new_cmptlevel = ] version Is the version of SQL Server with which the database is to be made compatible. version is tinyint, with a default of NULL. The value must be one of the following:

90 = SQL Server 2005 (9.x)

100 = SQL Server 2008 (10.0.x)

110 = SQL Server 2012 (11.x)

120 = SQL Server 2014 (12.x)

130 = SQL Server 2016 (13.x)

Return Code Values

0 (success) or 1 (failure)

Result Sets

If no parameters are specified or if the name parameter is not specified, sp_dbcmptlevel returns an error.

If name is specified without version, the Database Engine returns a message displaying the current compatibility level of the specified database.

Remarks

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

Permissions

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

See Also

Database Engine Stored Procedures (Transact-SQL)
ALTER DATABASE (Transact-SQL)
Reserved Keywords (Transact-SQL)
System Stored Procedures (Transact-SQL)