Databases Data platform complete template-specs-five-use-cases template-specs-five-use-cases-three-case-studies

SQL compatibility level

SQL compatibility level is the setting that tells the database engine which version-style behaviors a database should use for certain T-SQL and query-optimizer features. It lets a team move a database to a newer Azure SQL platform while keeping some older application behavior until testing proves the workload is ready. It does not freeze the entire engine in the past, and it is not the same as SKU or service tier. Treat it as a controlled modernization setting that can change query plans, feature behavior, and application assumptions.

Aliases
database compatibility level, compatibility_level, SQL Server compatibility level, Azure SQL compatibility level
Difficulty
intermediate
CLI mappings
6
Last verified
2026-05-24

Microsoft Learn

Microsoft Learn explains that compatibility level controls database behavior for SQL Server, Azure SQL Database, and Azure SQL Managed Instance. It can be viewed or changed with Transact-SQL, requires ALTER permission on the database, and should be evaluated because changes can affect applications and query optimization.

Microsoft Learn: View or change the compatibility level of a database2026-05-24

Technical context

In Azure architecture, SQL compatibility level is a database-scoped engine setting inside Azure SQL Database, SQL Managed Instance, SQL Server, and SQL database in Fabric. It is usually inspected with sys.databases and changed with ALTER DATABASE rather than basic Azure resource commands. The setting affects T-SQL behavior and query optimizer features, especially cardinality estimation and optimizer fixes. It fits into migration assessments, Query Store baselines, release testing, application compatibility reviews, and performance troubleshooting because the Azure control plane can host the database while the data plane honors database engine compatibility rules.

Why it matters

SQL compatibility level matters because migrations can fail quietly when engine behavior changes. An application may connect successfully to Azure SQL but produce slower queries, different execution plans, or unexpected behavior because compatibility level was raised without testing. Conversely, leaving old compatibility forever can block newer optimizer improvements and hide performance gains. The setting gives teams a staged path: migrate first, stabilize, capture Query Store baselines, test important queries, then raise compatibility intentionally. It is especially important for vendor applications, reporting systems, and older T-SQL code. A compatibility-level change should feel like a release event, not a casual database property edit.

Where you see it

Signals, screens, and Azure surfaces where this term usually becomes operational.

Signal 01

SSMS database properties and T-SQL queries against sys.databases show the current compatibility_level value for each user database being reviewed during migration testing. and release approval.

Signal 02

Migration assessment reports, Query Store baselines, and release checklists often record planned compatibility changes beside application owners, rollback commands, and performance comparison results. during production rollout reviews.

Signal 03

Azure CLI inventory does not replace T-SQL here, but it shows the exact server, database, resource group, region, and endpoint tied to the compatibility review.

When this becomes relevant

Specific situations where this term helps solve real Azure design, operations, migration, security, reliability, cost, or governance problems.

  • Keep a migrated database on an older compatibility level while validating application behavior on Azure SQL.
  • Raise compatibility in a controlled release to use newer optimizer behavior after Query Store baselines are captured.
  • Troubleshoot a sudden query regression by checking whether compatibility level changed during a deployment or restore.
  • Document vendor application exceptions where the supported compatibility level differs from the newest Azure SQL default.
  • Compare dev, test, and production databases so modernization does not silently drift across environments.

Real-world case studies

Different enterprise-style examples that show the term being used to hit measurable objectives.

Case study 01

Insurance migration separates move day from modernization

Scenario, objectives, solution, measured impact, and takeaway.

Scenario

An insurance claims platform moved from SQL Server to Azure SQL Database. The application connected successfully, but the vendor warned that raising compatibility level during migration would void support.

Business/Technical Objectives
  • Complete the platform migration without changing certified database behavior.
  • Create a path to test newer optimizer features after stabilization.
  • Avoid claim-processing delays during the renewal season.
  • Document every database compatibility exception for audit review.
Solution Using SQL compatibility level

The migration team kept each claims database at its supported compatibility level for the first production cutover. Azure CLI inventory mapped every database to a resource group, logical server, owner, and service objective. DBAs used T-SQL to record compatibility_level from sys.databases before and after restore. Query Store captured baseline queries during the first month in Azure SQL. After the renewal season, the team created a staging wave that raised compatibility on cloned databases and compared top stored procedures, claim-search reports, and nightly actuarial jobs. Exceptions were tracked with the application owner and vendor ticket number, so the modernization backlog was visible instead of forgotten.

Results & Business Impact
  • The cutover finished with zero compatibility-related production defects in the first two weeks.
  • Twelve databases received a documented modernization plan instead of an indefinite hold.
  • Two reporting procedures were tuned before compatibility was raised in production.
  • Audit evidence collection for database settings fell from three days to one scripted export.
Key Takeaway for Glossary Readers

Compatibility level lets teams migrate safely first, then modernize deliberately with owner sign-off and measured performance evidence.

Case study 02

Game analytics team fixes a silent plan shift

Scenario, objectives, solution, measured impact, and takeaway.

Scenario

A multiplayer game studio upgraded its analytics warehouse database and noticed leaderboard reports taking ten times longer. No network or SKU change appeared in the Azure portal.

Business/Technical Objectives
  • Find whether the regression came from engine behavior, data volume, or application deployment.
  • Restore leaderboard report speed before the weekend tournament.
  • Compare production and staging database settings reliably.
  • Create a repeatable check for future analytics database upgrades.
Solution Using SQL compatibility level

The data team used Azure CLI to confirm that production and staging had the same service objective, region, and logical server configuration. DBAs then queried sys.databases and found staging had a newer compatibility level than production after a restore test. Query Store showed different plans for the leaderboard aggregation procedure under the newer level. The team tuned the procedure and tested the target compatibility level against tournament traffic data before changing production. They added compatibility_level to their pre-release database checklist and stored the T-SQL output with Azure resource metadata so future investigations would not stop at portal properties.

Results & Business Impact
  • Leaderboard report duration returned from 94 seconds to 11 seconds after tuning.
  • Tournament support avoided a planned emergency scale-up of the database.
  • Release validation now catches compatibility drift across environments in under five minutes.
  • The team removed a recurring false assumption that Azure SKU was the only performance variable.
Key Takeaway for Glossary Readers

When query plans shift, compatibility level is one of the first database-scoped settings operators should verify.

Case study 03

Manufacturer protects a vendor ERP contract

Scenario, objectives, solution, measured impact, and takeaway.

Scenario

A manufacturer ran a vendor ERP system on Azure SQL Managed Instance. The vendor certified only specific compatibility levels, but internal developers wanted the newest optimizer behavior immediately.

Business/Technical Objectives
  • Keep ERP support coverage intact during database modernization.
  • Test compatibility changes against month-end inventory and invoicing jobs.
  • Prevent developers from changing database behavior outside change control.
  • Quantify whether newer compatibility improved the slowest stored procedures.
Solution Using SQL compatibility level

The platform team treated SQL compatibility level as a governed release setting. Azure CLI inventory exported managed instance and database metadata, while DBAs collected current compatibility values with T-SQL. The team cloned the ERP database to a test instance, raised compatibility level there, and replayed month-end workloads using production-like data. Query Store comparisons identified five procedures that benefited from newer optimizer behavior and three that needed vendor-approved changes. Production remained on the certified level until the vendor accepted the test evidence. Access to ALTER DATABASE was limited to the DBA group, and release notes included the planned monitoring and rollback window.

Results & Business Impact
  • Vendor support coverage remained valid throughout the modernization project.
  • Month-end inventory jobs improved by 18 percent after approved procedure changes.
  • Unauthorized compatibility changes dropped to zero after permission cleanup.
  • The upgrade decision moved from opinion to evidence backed by workload replay results.
Key Takeaway for Glossary Readers

Compatibility level decisions should respect vendor support, real workload testing, and database permissions, not just the desire to use the newest setting.

Why use Azure CLI for this?

From an Azure engineering perspective, Azure CLI is useful around compatibility level even though the exact value is normally viewed or changed with T-SQL. CLI gives the repeatable cloud inventory: which subscription, logical server, database, region, service objective, identity, firewall, and private endpoint are involved before a DBA runs ALTER DATABASE. That context prevents testing the wrong database or opening the wrong network path. In migrations, CLI scripts export database lists and owners so teams can attach compatibility test results to each Azure resource. It also helps pipelines gate a compatibility change by verifying the target database, diagnostic settings, Query Store evidence location, and change window before T-SQL is executed.

CLI use cases

  • List target Azure SQL databases before attaching T-SQL compatibility test results to each resource.
  • Show server and database metadata so DBAs confirm they are querying the intended environment.
  • Export database resource IDs, owners, and service objectives for migration wave planning.
  • Check firewall, private endpoint, and Entra admin settings before running compatibility validation queries.
  • Collect performance metrics around the same change window used for ALTER DATABASE compatibility testing.

Before you run CLI

  • Confirm the tenant, subscription, resource group, logical server, database, and environment label before preparing compatibility evidence.
  • Remember that viewing or changing compatibility level requires T-SQL access and ALTER permission for changes.
  • Do not open firewall rules broadly just to run validation; prefer approved private connectivity or temporary controlled access.
  • Capture Query Store baselines and application test coverage before raising compatibility in production.
  • Use JSON output for cloud inventory so results can be attached to migration and release records.

What output tells you

  • Database metadata confirms the Azure resource that corresponds to the T-SQL compatibility-level result.
  • Server and endpoint fields show where validation queries should connect and which network path is involved.
  • Firewall and private endpoint output reveals whether a failed validation is connectivity-related, not a compatibility issue.
  • Metric output helps compare CPU, IO, and duration before and after the compatibility-level change.
  • Resource tags and owners identify who must approve exceptions or application-specific compatibility holds.

Mapped Azure CLI commands

Azure SQL compatibility-level inventory support

adjacent-migration-operations
az sql server show --name <server> --resource-group <resource-group>
az sql serverdiscoverDatabases
az sql db list --server <server> --resource-group <resource-group>
az sql dbdiscoverDatabases
az sql db show --name <database> --server <server> --resource-group <resource-group>
az sql dbdiscoverDatabases
az sql server ad-admin show --server <server> --resource-group <resource-group>
az sql server ad-admindiscoverDatabases
az sql server firewall-rule list --server <server> --resource-group <resource-group>
az sql server firewall-rulediscoverDatabases
az monitor metrics list --resource <database-resource-id> --metric cpu_percent,dtu_consumption_percent,storage_percent --interval PT5M
az monitor metricsdiscoverDatabases

Architecture context

Architecturally, compatibility level is a bridge between application modernization and platform modernization. I do not treat it as a one-time migration checkbox. I map each database to an application owner, critical queries, Query Store baseline, rollback plan, and target compatibility level. Azure SQL may run on a modern platform while the database remains at an older compatibility level until testing is complete. That is useful, but it can also create long-lived technical debt. The safest design raises compatibility in stages across dev, test, staging, and production, with performance comparison and business sign-off. For Managed Instance and SQL Server estates, align compatibility decisions with vendor support and engine update policy.

Security

Security impact is indirect. Compatibility level does not grant access, expose a network endpoint, or encrypt data. Risk appears when teams change it without understanding application behavior, because broken code paths can bypass normal operational controls or trigger emergency access. Security teams should still care during migrations because compatibility testing often runs alongside authentication, firewall, and data-protection changes. Limit who can alter database settings, record the change in deployment history, and protect Query Store or performance evidence that may contain query text. If a compatibility change is part of regulated application certification, keep approval records and test results with the release evidence.

Cost

Cost impact is indirect but meaningful. A higher compatibility level can unlock optimizer improvements that lower CPU, IO, memory, and service-tier pressure. It can also introduce plan changes that make some queries more expensive until tuned. Leaving databases at older levels may force teams to buy capacity to mask inefficient plans that newer behavior could improve. Migration projects also spend money on testing, DBA effort, and performance analysis, so grouping compatibility reviews with release cycles can reduce duplicated work. The cost decision should include query performance, vendor support, testing effort, and the risk of emergency troubleshooting after an unplanned compatibility change.

Reliability

Reliability impact is direct for application stability. A compatibility-level change can alter query optimization behavior and expose old assumptions in T-SQL code. The database may stay online, yet users see timeouts, different report results, or degraded workflows. Reliable change practice means testing representative queries, capturing Query Store baselines, using staging environments, and preparing rollback to the previous level if problems appear. Existing databases are not automatically upgraded by Microsoft, so customers own the decision. During migrations, keep the compatibility level stable until the workload is validated. During modernization, raise it deliberately and monitor for regressions before declaring success. Monitor users before rollout.

Performance

Performance impact is direct because compatibility level influences optimizer behavior, cardinality estimation, and which engine improvements are active for the database. Raising the level can improve many workloads, but it can also expose plan regressions for important queries. Query Store is the practical safety tool: capture a baseline, compare top queries, and use tuning or plan correction when needed. Do not judge performance from one synthetic query. Test reports, batch jobs, parameter-sensitive procedures, and peak user paths. The goal is not always the newest level immediately; the goal is a tested level that supports application correctness and predictable performance. Measure results under load.

Operations

Operators inspect compatibility level by querying sys.databases and documenting the value beside the Azure SQL database resource. Operational work includes migration readiness, change approvals, Query Store comparison, release validation, and exception tracking for vendor applications. Azure CLI helps locate the database and confirm the surrounding Azure resource configuration, while DBAs run T-SQL to view or change the engine setting. After a change, operators watch top queries, waits, CPU, duration, and application errors. Good runbooks include who can approve the change, what workload must be tested, how long to monitor, and the exact rollback command if application behavior regresses. Review outcomes regularly.

Common mistakes

  • Changing compatibility level in production without representative Query Store baselines and application test results.
  • Assuming Azure SQL platform version and database compatibility level are the same thing.
  • Leaving old compatibility levels forever because the migration succeeded and nobody owns modernization.
  • Testing only simple queries while ignoring reporting, batch jobs, stored procedures, and parameter-sensitive workloads.
  • Blaming Azure networking for failures that are actually T-SQL behavior changes after compatibility was raised.