Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to check SQL Server Database compatibility after sp_dbcmptlevel is deprecated?

According to BOL (SQL Server Books Online) on sp_dbcmptlevel,

This feature will be removed in a future version of Microsoft SQL Server. Do not use this feature in new development work, and modify applications that currently use this feature as soon as possible. Use ALTER DATABASE Compatibility Level instead.

Now, the only TSQL way I know of checking database compatibility is through sp_dbcmptlevel. As far as I know, ALTER DATABASE Compatibility Level is just for setting the compatibility level, not getting info.

How should one to get compatibility level without using GUI?

like image 631
dance2die Avatar asked Oct 01 '09 02:10

dance2die


People also ask

How do I check SQL Server compatibility level?

Right-click the database, and then select Properties. The Database Properties dialog box opens. In the Select a page pane, select Options. The current compatibility level is displayed in the Compatibility level list box.

How do I upgrade my SQL Server compatibility level?

It's really simple to change the database compatibility level. In SQL Server Management Studio (SSMS), right-click on the database name, select Properties, select the Options node, click on the drop-down next to Compatibility level and select the level that matches your SQL Server.

When was SQL Server mirroring deprecated?

As of February 2016, Microsoft states: “[Database Mirroring] will be removed in a future version of Microsoft SQL Server. Avoid using this feature in new development work, and plan to modify applications that currently use this feature.


2 Answers

select name, compatibility_level , version_name =  CASE compatibility_level     WHEN 65  THEN 'SQL Server 6.5'     WHEN 70  THEN 'SQL Server 7.0'     WHEN 80  THEN 'SQL Server 2000'     WHEN 90  THEN 'SQL Server 2005'     WHEN 100 THEN 'SQL Server 2008/R2'     WHEN 110 THEN 'SQL Server 2012'     WHEN 120 THEN 'SQL Server 2014'     WHEN 130 THEN 'SQL Server 2016'     WHEN 140 THEN 'SQL Server 2017'     WHEN 150 THEN 'SQL Server 2019'     ELSE 'new unknown - '+CONVERT(varchar(10),compatibility_level) END from sys.databases 
like image 165
Nick Kavadias Avatar answered Sep 20 '22 20:09

Nick Kavadias


select compatibility_level from sys.databases where name ='myDB' 
like image 29
mjv Avatar answered Sep 20 '22 20:09

mjv