Database compatibility


Job details

Name: Database compatibility
Platform: Sqlserver
Category: Security
Description: Checks if there is a difference in compatibility levels of databases and the instance.
Long description: Checks if there is a difference in compatibility levels of databases and the instance.
Version: 1.3
Default schedule: 9 1 1 *
Requires engine install: Yes
Compatibility tag: .[type=‘instance’ & databasetype=‘sqlserver’]/instance[maj_version > ‘2005′ & hasengine=‘YES’ & eng_inst_priv = 0 & (engine_edition = ‘Microsoft SQL Server’ engine_edition = ‘Azure SQL Managed Instance’)]

Parameters

Name Default value Description
ignore databases model List of databases (separated by comma) which will be ignored. You can use % (percent sign) to represent wild card characters.
return status 1 Return status value (ALARM – 2, WARNING – 1, or OK – 0) when any database are in lower compatibility level than master database.
enforce compatibility NO If set to “YES“ the alert will enforce instance compatibility for every databases by running ALTER DATABASE [db_name] SET COMPATIBILITY_LEVEL.
history threshold 365 The maximum number of day to kept statistics for in the historic tables.

Job Summary

SELECT name, compatibility_level FROM sys.databases;

Job Description

The “Database compatibility” job checks if there is any difference in the compatibility levels between the databases and the SQL Server instance’s master database. It creates and uses several objects in the SQL instance, such as tables to store current compatibility information and a history of changes, and a stored procedure to perform the checks and possibly enforce the preferred compatibility level.

Dependencies

These objects are critical for the operation as they store and handle data required during the execution of the job.

Parameters Impact (Descriptive Purpose Only, No Deep Details)

Implementation Details

The procedure `dbw_db_compatibility_proc` carries out the following operations:

During execution, detailed logs and return statuses are managed to indicate the success or failure of the operation along with a description of what was processed.

Output Report Summary

Current Database Compatibility

Database Compatibility Level Compatibility
Master 140 2017
OtherDB 100 2008

Aggregated Statistics

Database
Compatibility
Instance Compatibility
First time registered
Last time registered
Times check

Conclusion

This monitoring job is essential for maintaining consistency in compatibility levels across databases in a SQL Server instance. It provides both preventive measures and corrective actions to manage database compatibility effectively.