Welcome back. A job-ready DBA does not just “install SQL Server and hope for the best.”
DBAs harden an instance by eliminating settings that quietly create performance problems, instability,
and avoidable outages. Many of these problems come from database options that were enabled accidentally,
carried over from old environments, or left at defaults that do not match production behavior.
In this lesson, you will learn three critical database options:
Compatibility Level, AUTO_CLOSE, and AUTO_SHRINK.
You will learn what they do, why AUTO_CLOSE and AUTO_SHRINK are commonly considered harmful,
and how to audit and standardize these settings with evidence.
Lesson description: You will learn how compatibility level affects SQL Server behavior and query optimization,
why DBAs manage it intentionally during upgrades, and how to validate changes safely. You will also learn why
AUTO_CLOSE and AUTO_SHRINK are widely treated as “do not use” options in production:
they can cause repeated open/close overhead, cache churn, file fragmentation, and unpredictable performance.
You will practice auditing all databases for these options, fixing them safely, and documenting the change.
Every SQL Server database has a compatibility level.
It tells SQL Server which behavior “mode” to apply for that database,
especially for query optimizer behaviors and certain language features.
Why DBAs care: During SQL Server upgrades, databases may keep an older compatibility level to reduce risk.
But staying on a very old compatibility level can block optimizer improvements and newer features.
Lab goal: Learn to audit and understand the setting now, so you can manage it professionally later.
AUTO_CLOSE closes the database and releases resources when the last user disconnects.
This may sound “efficient,” but in real workloads it usually causes problems.
Why it’s harmful: When the database closes and later reopens, SQL Server may have to rebuild internal state
and reload things that would normally stay warm. That leads to:
DBA standard: AUTO_CLOSE should almost always be OFF for production databases.
It is commonly seen in desktop/single-user scenarios, not server workloads.
AUTO_SHRINK tries to automatically shrink database files to reclaim space.
This is one of the most universally discouraged options in SQL Server administration.
Why it’s harmful: Shrinking moves pages around inside the data file, which can:
DBA standard: AUTO_SHRINK should be OFF in production.
If you truly must reclaim space, DBAs do controlled one-time shrink operations (rare),
and then fix the root cause and pre-size appropriately.
Run this audit query. It shows compatibility level, AUTO_CLOSE, and AUTO_SHRINK for all databases.
This is the kind of script a DBA runs during server onboarding.
SELECT
name AS database_name,
compatibility_level,
is_auto_close_on,
is_auto_shrink_on,
state_desc,
recovery_model_desc
FROM sys.databases
ORDER BY name;
Save output to:
C:\DBA\Baselines\InstanceConfig\db_options_before_YYYYMMDD_HHMM.txt
In your lab, you will practice turning off AUTO_CLOSE and AUTO_SHRINK for a user database.
Use a controlled change:
-- Replace [YourDatabaseName] with your actual database name ALTER DATABASE [YourDatabaseName] SET AUTO_CLOSE OFF; ALTER DATABASE [YourDatabaseName] SET AUTO_SHRINK OFF;
Rollback plan (if needed):
-- Rollback example (rarely recommended in real production) ALTER DATABASE [YourDatabaseName] SET AUTO_CLOSE ON; ALTER DATABASE [YourDatabaseName] SET AUTO_SHRINK ON;
In real environments, rollback would be unusual because these options are typically disabled for stability.
But as a DBA you always document the rollback path anyway.
Changing compatibility level can change query plans. That can improve performance or cause regressions.
DBAs treat it like a controlled release:
In your lab, you can practice the command:
-- Example: set compatibility level (replace level and database as needed) -- You should only do this intentionally and document why. ALTER DATABASE [YourDatabaseName] SET COMPATIBILITY_LEVEL = 160;
Lab guidance: You do not need to change compatibility level unless you are practicing the workflow.
The most important skill is understanding the impact and how to validate safely.
Re-run the audit query and save your after snapshot:
Save output to:
C:\DBA\Baselines\InstanceConfig\db_options_after_YYYYMMDD_HHMM.txt
db_options_before_YYYYMMDD_HHMM.txtdb_options_after_YYYYMMDD_HHMM.txtC:\DBA\Logs\Changes\change_note_db_options_YYYYMMDD_HHMM.txtNext, you will bundle your work from Section 7 into a professional baseline configuration:
memory, MAXDOP/CTFP, file growth, tempdb, Agent checks, and database options—then produce a documented report
you can use as portfolio evidence.
Not a member yet? Register now
Are you a member? Login now