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

Troubleshooting Guide: SQL Server Error 2218 — “There is no attribute named ‘@%ls'”

Why This Error Happens

Error 2218 occurs when SQL Server’s XML parser processes an XML-formatted configuration file, SSIS package, or XML schema collection and encounters an attribute reference that doesn’t exist in the current node context. This is typically caused by a corrupted or manually-edited XML file (such as a Policy-Based Management policy, Maintenance Plan, or SSIS .dtsx package) where an attribute was renamed, removed, or mistyped during an incomplete version upgrade or migration. It can also surface when a third-party tool or extension generates malformed XML that references deprecated attributes no longer supported in SQL Server 2025’s updated XML schema definitions.

Step-by-Step Resolution Guide

Step 1: Identify the Source XML File or Object

  • Check the SQL Server error log at C:\Program Files\Microsoft SQL Server\MSSQL17.MSSQLSERVER\MSSQL\Log\ERRORLOG for the full stack trace surrounding Error 2218.
  • Note the specific attribute name (@%ls is a placeholder populated at runtime) and the object type (SSIS package, Policy, Extended Event session, etc.).
  • If triggered by an SSIS job, open SQL Server Agent job history under Object Explorer > SQL Server Agent > Jobs to pinpoint the exact step and package path.

Step 2: Validate the XML Against Its Schema

  • Open the suspect .dtsx, .xml, or .policy file in a text editor (Notepad++ or VS Code) and locate the attribute referenced in the error.
  • Run Invoke-XmlValidation in PowerShell (or use xmllint --noout --schema schema.xsd file.xml if the Linux tools are installed) to confirm the file conforms to its expected XSD.
  • Compare the file against a known-good backup copy stored in version control or a prior deployment package.

Step 3: Repair or Regenerate the Corrupted Object

  • If it’s an SSIS package, reopen the project in SQL Server Data Tools (SSDT) 2025, rebuild the package, and redeploy it via dtutil or the Integration Services Catalog.
  • If it’s a Policy-Based Management policy, drop and reimport the policy using Import-SqlPolicy or re-export a clean copy from a healthy instance.
  • For Extended Events sessions, run DROP EVENT SESSION [SessionName] ON SERVER; followed by a fresh CREATE EVENT SESSION script generated from the current catalog views.

Step 4: Clear Cached Metadata and Restart Services

  • Stop the SQL Server service via Stop-Service -Name 'MSSQLSERVER' in an elevated PowerShell session.
  • Clear any cached plan or policy cache using DBCC FREESYSTEMCACHE('ALL') before shutdown if the instance is still responsive.
  • Restart the service with Start-Service -Name 'MSSQLSERVER' and monitor the ERRORLOG for recurrence.

Alternative or Verification Steps

  • Re-run the operation that originally triggered Error 2218 (job execution, policy evaluation, or package deployment) and confirm the ERRORLOG shows no further XML parsing errors.
  • If the error persists, use sp_helptext or OBJECT_DEFINITION() to extract any embedded XML from system objects and manually diff it against Microsoft’s documented schema for SQL Server 2025 to isolate the invalid attribute.