Skip to content

Disable AUTO_CLOSE On Contained Database


A database with AUTO_CLOSE enabled will be shutdown as soon as all connections to the database are closed. If a new connection is created to a database in a shut down state, it will take time to re-initialize, potentially leading to errors and timeouts.

For more information, see Recommendations and guidelines for setting the AUTO_CLOSE database option in SQL Server


This rule checks whether the AUTO_CLOSE option is set OFF. When AUTO_CLOSE is set ON, this option can cause performance degradation on frequently accessed databases because of the increased overhead of starting and shutting down the database.

For more information, see Set the AUTO_CLOSE Database Option to OFF

Applies To

  • Databases


This rule is applied when the following tags are present:

Tag With Value
secureclouddb/provider aws
secureclouddb/service rds
secureclouddb/engine sqlserver

Default Rule

const { isEmptyArray } = module

 * @param {Object} databaseSettings - database settings object
 * @returns {boolean} true if 'autoClose' is set to On
function validate(databaseSettings) {
    const success = isEmptyArray(databaseSettings.databases) ||
                        databaseSettings.databases.filter(database =>
                            database.sqlserver.containment !== 0 &&

    return {