Troubleshooting Guide: SQL Server Error 6933 – “XML Validation: Invalid Simple Type Operation”
Why This Error Happens
This error occurs when SQL Server’s XML parser attempts to validate an XML instance against an XML Schema Collection (XSD) and encounters a simple type (such as an attribute or element value) that does not conform to the facets, restrictions, or data type defined in the schema. This is commonly triggered by corrupted XML data, a mismatched or outdated XML Schema Collection bound to the column, or an application sending malformed data (e.g., incorrect date formats, out-of-range numeric values, or invalid enumeration values) that violates xs:simpleType restrictions. In some cases, this also surfaces after an in-place upgrade to SQL Server 2025 on Windows Server 2025, where stricter XSD compliance checks expose previously unvalidated legacy data.
Step-by-Step Resolution Guide
Step 1: Identify the Offending XML Data and Schema Collection
- Run
SELECT name, xml_collection_id FROM sys.xml_schema_collections;to list schema collections bound to your database. - Use
SELECT * FROM sys.dm_exec_describe_first_result_setor query the affected table directly to locate the specific row/column causing the validation failure. - Check the SQL Server Error Log (
C:\Program Files\Microsoft SQL Server\MSSQL17.MSSQLSERVER\MSSQL\Log\ERRORLOG) for the exact XPath or element name referenced in the 6933 error.
Step 2: Validate and Correct the XML Instance
- Extract the problematic XML value using
SELECT CAST(xml_column AS NVARCHAR(MAX)) FROM YourTable WHERE PrimaryKey = X;. - Open the extracted XML in a validation tool (Visual Studio 2022/2025 XML Editor or
xmllint.exe) against the associated.xsdfile. - Correct data type mismatches manually — for example, ensure
xs:datefields useYYYY-MM-DDformat andxs:integerfields do not contain decimal or alphanumeric values. - Re-insert or update the corrected XML using
UPDATE YourTable SET xml_column = @FixedXml WHERE PrimaryKey = X;.
Step 3: Rebuild or Refresh the XML Schema Collection
- If the schema itself is outdated, drop and recreate it:
DROP XML SCHEMA COLLECTION dbo.YourSchemaCollection;. - Re-register the corrected XSD using
CREATE XML SCHEMA COLLECTION dbo.YourSchemaCollection AS N'<xsd content>';. - Restart the SQL Server (MSSQLSERVER) service via
services.mscorRestart-Service MSSQLSERVERin PowerShell (run as Administrator) to clear any cached schema metadata.
Step 4: Check for Application-Layer Data Submission Issues
- Review the application or ETL pipeline (SSIS package, .NET DataSet, or API payload) generating the XML to ensure it enforces the same type constraints as the SQL Server schema collection.
- Add client-side validation using
System.Xml.Schema.XmlSchemaSetin .NET before submitting data to SQL Server, preventing malformed XML from reaching the database layer.
Alternative or Verification Steps
- Verify the fix by re-running the original INSERT/UPDATE statement or application transaction that triggered Error 6933 — it should now complete without validation errors.
- Alternative approach: If schema strictness is not business-critical, temporarily store the data as untyped
XML(without a schema collection) to unblock operations, then re-apply validation once the root data issue is resolved.