Some databases might not have their compatibility levels set to the most recent version of SQL Server which is installed. I want to automate that detection without ever typing in the current compatibility level, how can I identify them through T-SQL?
1条答案
按热度按时间bq3bfh9z1#
SERVERPROPERTY('ProductVersionMajor')
returns the version number i.e. 14.The
compatibility_level
insys.databases
for a new database in version 14 will be 140.Hence here I multiply by 10
However, application vendors may not have tested their code with this compatibility level, so it is not always safe to assume you can alter every database to match the current server level.
This doesn't work for azure databases because Microsoft Went totally loopy with their version numbering. see this article