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

Troubleshooting Guide: SQL Server Error 2390 – “Top-level %s nodes are not supported”

Why This Error Happens

This error typically occurs when SQL Server’s XML parser encounters an XML document or schema definition that contains multiple top-level nodes, or a top-level node type (such as a DTD declaration or processing instruction) that is not supported by the SQL Server XML engine. It is commonly triggered during XML schema collection imports, SSIS package execution, or when application code passes malformed XML into an XML-typed column or OPENXML/sp_xml_preparedocument call. This can also surface after an in-place upgrade to SQL Server 2025 on Windows Server 2025, where stricter XML parsing validation was introduced compared to legacy engines.

Step-by-Step Resolution Guide

Step 1: Validate the Source XML Document

  • Open the XML file or payload causing the error in a text editor or XML validator (e.g., Visual Studio, Notepad++ with XML plugin).
  • Confirm there is only one root-level element; SQL Server’s XML type requires a single top-level node.
  • Remove any extraneous top-level comments, multiple root elements, or stray processing instructions outside the root node.

Step 2: Check for Unsupported DTD or Processing Instructions

  • Search the XML for <!DOCTYPE ...> declarations — SQL Server’s XML parser does not support DTDs at the top level.
  • Strip out any <?xml-stylesheet?> or custom processing instructions placed before or after the root element.
  • If using sp_xml_preparedocument, ensure the input string passed is a fully well-formed single-document XML, not a fragment with multiple siblings.

Step 3: Review the Import/Integration Pipeline

  • If using SSIS, open the package in SQL Server Data Tools and inspect the XML Source component configuration.
  • Check the XSD/Schema Collection referenced by CREATE XML SCHEMA COLLECTION for multiple top-level <xs:schema> definitions and consolidate them into one.
  • Update any .NET or PowerShell ingestion scripts to wrap multi-record payloads in a single enclosing root element before insertion.

Step 4: Apply Latest SQL Server 2025 Cumulative Update

  • Navigate to Microsoft Update Catalog and confirm the instance is running the latest Cumulative Update (CU) for SQL Server 2025.
  • Run the following in SSMS to check the current build:
  • SELECT @@VERSION;
  • Install any pending CU via Windows Server 2025’s Server Manager or the standalone SQL Server Installer, then restart the MSSQLSERVER service.

Step 5: Re-test the XML Operation

  • Re-run the original INSERT, CREATE XML SCHEMA COLLECTION, or SSIS task against the corrected XML file.
  • Monitor the SQL Server Error Log (Management > SQL Server Logs in SSMS) to confirm Error 2390 no longer appears.

Alternative or Verification Steps

  • Verify the fix by executing SELECT CAST(@XmlVariable AS XML); against the corrected payload in a test query window — it should return without error.
  • If the issue persists, use sp_xml_removedocument to clear any cached XML document handles, then reattempt with a freshly validated XML fragment to rule out memory/handle corruption.