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

Troubleshooting Guide: SQL Server Error 2372

Why This Error Happens

Error 2372 occurs when SQL Server’s metadata schema validation encounters an XML or DDL attribute (denoted as @%ls:%ls) that is being applied to an element or object type (%ls) that does not support it. This typically happens due to a mismatch between a metadata annotation—such as a namespace-prefixed attribute used in XML schema collections, CLR integration, or Service Broker definitions—and the target object’s supported attribute set. It can also surface after an in-place upgrade to SQL Server 2025 where deprecated or renamed metadata attributes remain referenced in legacy scripts, stored procedures, or SSIS packages that were not updated for the new schema validation engine.

Step-by-Step Resolution Guide

Step 1: Identify the Offending Script or Object

  • Open SQL Server Management Studio (SSMS) and check the Activity Monitor or SQL Server Error Log (Management > SQL Server Logs) to capture the full error text, including the specific attribute and object name reported.
  • Run the following query to pinpoint recent DDL operations that may have triggered the validation failure:
  SELECT * FROM sys.fn_xe_file_target_read_file('system_health*.xel', NULL, NULL, NULL) WHERE object_name = 'error_reported';
  • Note the exact namespace prefix and attribute name from the error message for cross-referencing in Step 2.

Step 2: Validate XML Schema Collections and Metadata Definitions

  • Navigate to Object Explorer > Databases > [YourDB] > Programmability > Types > XML Schema Collections and inspect any collection referenced by the failing object.
  • Use sp_help or query sys.xml_schema_collections to confirm the attribute is valid for the SQL Server 2025 schema version:
  SELECT * FROM sys.xml_schema_collections WHERE name = 'YourSchemaCollectionName';
  • Remove or correct any deprecated attributes (common culprits include legacy sql: or xsi: prefixed attributes not supported on newer element types like sparse columns or temporal table metadata).

Step 3: Update or Recompile Affected Stored Procedures/SSIS Packages

  • Open any stored procedures, functions, or SSIS packages that reference the object in question via C:\Program Files\Microsoft SQL Server\160\DTS\Packages\ (or your custom deployment path).
  • Replace outdated metadata attribute calls with the SQL Server 2025-compliant syntax found in the Breaking Changes section of Microsoft Docs for the 2025 release.
  • Recompile using:
  EXEC sp_recompile 'YourStoredProcedureName';

Step 4: Apply the Latest Cumulative Update (CU)

  • Check your current build via SELECT @@VERSION; and compare against the latest CU listed on the Microsoft Update Catalog.
  • Download and install the newest Cumulative Update for SQL Server 2025, as metadata validation bugs are frequently patched in CU releases.
  • Restart the SQL Server (MSSQLSERVER) service via services.msc or net stop MSSQLSERVER && net start MSSQLSERVER after installation.

Alternative or Verification Steps

  • Re-run the original DDL statement or SSIS package in a test/staging environment and confirm Error 2372 no longer appears in the SQL Server Error Log.
  • If the error persists, use DBCC CHECKDB with the WITH DATA_PURITY option to rule out underlying metadata corruption, and consider restoring the schema collection from a known-good backup if corruption is confirmed.