Compatibility levels with MSSQL
- Microsoft SQL Server keeps track of the compatibility level at the database level.
- The features of the new version/upgrade are only available if the database compatibility level are changed to the new level level.
- The current compatibility levels are:
- 60 for MSSQL 6
- 65 for MSSQL 6.5
- 70 for MSSQL 7
- 80 for MSSQL 2000
- 90 for MSSQL 2005
- The compatibility levels represent the version numbers.
- The changes/upgrades of the SQL Server may/do not work with specific database unless you change the database compatibility level.
Applied to:
- Microsoft SQL Server 2000
- Microsoft SQL Server 2005
Database compatibility level
You can view the database compatibility level and change them with: sp_dbcomptlevel.
- PRINT 'Master: ' EXEC sys.SP_DBCMPTLEVEL 'master';
- PRINT '-----------------------';
- go
- PRINT 'Tempdb: ' EXEC sys.SP_DBCMPTLEVEL 'tempdb';
- PRINT '-----------------------';
- go
- PRINT 'Model: ' EXEC sys.SP_DBCMPTLEVEL 'model';
- PRINT '-----------------------';
- go
- PRINT 'Msdb: ' EXEC sys.SP_DBCMPTLEVEL 'msdb';
- PRINT '-----------------------';
- go
- PRINT 'ReportServer: ' EXEC sys.SP_DBCMPTLEVEL 'ReportServer';
- PRINT '-----------------------';
- go
- PRINT 'ReportServerTempDB: ' EXEC sys.SP_DBCMPTLEVEL 'ReportServerTempDB';
- PRINT '-----------------------';
- go
- PRINT 'AdventureWorksDW: ' EXEC sys.SP_DBCMPTLEVEL 'AdventureWorksDW';
- PRINT '-----------------------';
- go
- PRINT 'AdventureWorks: ' EXEC sys.SP_DBCMPTLEVEL 'AdventureWorks';
- PRINT '-----------------------';
- go
- PRINT 'AdventureWorksLT: ' EXEC sys.SP_DBCMPTLEVEL 'AdventureWorksLT';
- PRINT '-----------------------';
- go
- PRINT 'sql911: ' EXEC sys.SP_DBCMPTLEVEL 'sql911';
- PRINT '-----------------------';
- go
Master: The current compatibility level is 90. ----------------------- Tempdb: The current compatibility level is 90. ----------------------- Model: The current compatibility level is 90. ----------------------- Msdb: The current compatibility level is 90. ----------------------- ReportServer: The current compatibility level is 90. ----------------------- ReportServerTempDB: The current compatibility level is 90. ----------------------- AdventureWorksDW: The current compatibility level is 90. ----------------------- AdventureWorks: The current compatibility level is 90. ----------------------- AdventureWorksLT: The current compatibility level is 90. ----------------------- sql911: The current compatibility level is 90. -----------------------
- Each sp_dbcmptlevel must be submitted individually.
- sp_dbcmptlevel can only be called ad hoc. If you called sp_dbcmptlevel from a batch or procedure, exec or a batch, you will get:
Msg 15432, Level 16, State 1, Procedure sp_dbcmptlevel, Line 28Stored procedure 'sys.sp_dbcmptlevel' can only be executed at the ad hoc level.
- To get a list of all the databases use:
- EXEC sp_msforeachdb 'print ''?'' '
- go
master tempdb model msdb ReportServer ReportServerTempDB AdventureWorksDW AdventureWorks AdventureWorksLT sql911
Change the database compatibility level
To change the database compatibility level just add the level needed after the database.
- EXEC SP_DBCMPTLEVEL AdventureWorks, 80;
- go
- PRINT 'AdventureWorks: ' EXEC sys.SP_DBCMPTLEVEL 'AdventureWorks';
- PRINT '-----------------------';
- go
DBCC execution completed. If DBCC printed error messages, contact your system administrator. AdventureWorks: The current compatibility level is 80. ----------------------- DBCC execution completed. If DBCC printed error messages, contact your system administrator. AdventureWorks: The current compatibility level is 90. -----------------------

