I have a mixed environment of servers from 2000 to 2012, and I'd like to find any databases that have a compatibility level set less than the version of the server it is running on.
Ideally, I'd like to do something like:
SELECT name, compatibility_level FROM master.sys.databases WHERE compatibility_level <> SERVERPROPERTY('productcompatibilitylevel')
but that unfortunately doesn't exist. Instead I'm having to do a big CASE statement based on SERVERPROPERTY('productversion'). Any better ways to do this?