How to fix Error 9539 on Windows Server 2025 / Windows 11

Troubleshooting Guide: Error 9539 – Selective XML Index Not Supported for Current Database Version

Why This Error Happens

Error 9539 occurs when a database attempting to use Selective XML Indexes (SXI) is still operating at a compatibility level below the minimum required for this feature, typically because the database was migrated or restored from an older SQL Server instance without updating its compatibility level. This can also occur if the database is still in the process of being upgraded internally, leaving catalog metadata inconsistent with SQL Server 2025 engine expectations. Additionally, corrupted system catalog views related to XML schema collections can trigger this error even on databases that appear to be at the correct version.

Step-by-Step Resolution Guide

Step 1: Verify the Current Database Compatibility Level

  • Open SQL Server Management Studio (SSMS) and connect to your SQL Server 2025 instance.
  • Run the following query to check the current compatibility level:
  SELECT name, compatibility_level FROM sys.databases WHERE name = 'YourDatabaseName';
  • Confirm the value is below 170 (SQL Server 2025 baseline), which indicates the database has not been upgraded.

Step 2: Upgrade the Database Compatibility Level

  • Execute the following T-SQL command to raise the compatibility level:
  ALTER DATABASE [YourDatabaseName] SET COMPATIBILITY_LEVEL = 170;
  • Ensure no active transactions or blocking sessions are running against the database during this change.
  • Restart the SQL Server service via services.msc on Windows Server 2025 if the setting does not apply immediately.

Step 3: Rebuild XML Schema Collection Metadata

  • Navigate to the affected database in SSMS and locate the XML Schema Collections under Programmability > Types > XML Schema Collections.
  • Drop and recreate any XML Schema Collections tied to the Selective XML Index using:
  DROP XML SCHEMA COLLECTION [SchemaName];
  CREATE XML SCHEMA COLLECTION [SchemaName] AS N'<schema definition>';
  • Re-run the CREATE SELECTIVE XML INDEX statement to confirm the feature is now recognized.

Step 4: Validate SQL Server Instance Patch Level

  • Open a PowerShell terminal as Administrator and check the installed SQL Server build:
  SELECT @@VERSION;
  • Confirm the build number matches the latest Cumulative Update (CU) for SQL Server 2025, as early RTM builds may have incomplete SXI feature support.
  • Apply the latest CU from the Microsoft Update Catalog if the build is outdated, then restart the SQL Server (MSSQLSERVER) service.

Alternative or Verification Steps

  • After completing the steps above, re-run your original CREATE SELECTIVE XML INDEX statement; if it executes without Error 9539, the compatibility level and schema metadata are correctly aligned.
  • As an alternative, if upgrading compatibility level is not immediately feasible, consider using standard XML indexes (CREATE PRIMARY XML INDEX) as a temporary workaround until the full database upgrade can be scheduled.