本文介绍了不建议使用sp_dbcmptlevel后如何检查SQL Server数据库兼容性?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

根据,

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

现在,我知道的唯一的TSQL检查数据库兼容性的方法是通过 sp_dbcmptlevel
据我所知,仅用于设置兼容性级别,而不获取信息。

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.

获得兼容性级别而不使用GUI?

How should one to get compatibility level without using GUI?

推荐答案

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

这篇关于不建议使用sp_dbcmptlevel后如何检查SQL Server数据库兼容性?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

06-09 05:50