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

Troubleshooting Guide: SQL Server Error 2270 – Duplicate Attribute

Why This Error Happens

Error 2270 (%sDuplicate attribute '%ls:%ls') occurs when SQL Server’s XML parser encounters a malformed XML document or schema definition that defines the same attribute name more than once within a single element tag. This is typically triggered during operations involving FOR XML queries, XML schema collections, or when importing/parsing XML configuration files (such as SSIS packages, Policy-Based Management policies, or Extended Events session definitions) that have become corrupted or manually edited incorrectly. It can also surface when a third-party tool or custom script generates XML with duplicate namespace attributes due to a bug in the application logic.

Step-by-Step Resolution Guide

Step 1: Identify the Source XML Causing the Error

  • Check the SQL Server Error Log at C:\Program Files\Microsoft SQL Server\MSSQL17.MSSQLSERVER\MSSQL\Log\ERRORLOG for the full stack trace accompanying Error 2270.
  • Identify whether the error originates from a stored procedure using FOR XML, an SSIS package (.dtsx), an XML Schema Collection (XSD), or an Extended Events (.xel) configuration.
  • Use sys.dm_exec_requests and sys.dm_exec_sql_text to find the exact query handle executing at the time of failure.

Step 2: Validate and Repair the XML Document

  • Extract the raw XML (e.g., from the SSIS package or the CREATE XML SCHEMA COLLECTION script) and open it in Visual Studio Code or XML Notepad 2025.
  • Manually scan the offending element for repeated attributes (e.g., <element xmlns:ns1="..." xmlns:ns1="...">).
  • Remove the duplicate attribute declaration, ensuring only one unique instance per element exists, then save the file with UTF-8 encoding.

Step 3: Re-deploy or Re-import the Corrected Schema

  • If the issue stems from an XML Schema Collection, drop and recreate it using: DROP XML SCHEMA COLLECTION dbo.YourSchemaName;
  • Re-run the CREATE XML SCHEMA COLLECTION command pointing to the newly sanitized XSD file.
  • For SSIS packages, re-import the corrected .dtsx file into the Integration Services Catalog (SSISDB) via SQL Server Management Studio (SSMS) 21.

Step 4: Check for Environment-Specific Corruption

  • If the error persists despite clean XML, verify the integrity of the MSXML parser components on Windows Server 2025 by running sfc /scannow in an elevated Command Prompt.
  • Ensure the SQL Server instance is patched to the latest Cumulative Update (CU) to rule out a known parser bug in the initial RTM build.

Alternative or Verification Steps

  • Verify the Fix: Re-run the specific query or redeploy the SSIS package/schema collection; if Error 2270 does not reappear in the Activity Monitor or Error Log, the duplicate attribute has been successfully resolved.
  • Alternative Solution: If editing the source XML is not feasible, use a TRY...CATCH block in T-SQL to pre-validate XML variables with TRY_CAST or sys.fn_validate_plan_guide before execution to gracefully handle malformed data without crashing the session.