Why This Error Happens
This error occurs when SQL Server attempts to register or parse an XML Schema Collection (XSD) that contains a <xs:restriction base="xs:QName"> definition. SQL Server’s native XML type system has a hard-coded limitation where it cannot process derived simple types that restrict the built-in QName data type, regardless of the Windows Server or SQL Server build version. This is typically triggered by importing a third-party WSDL, SOAP schema, or a complex XSD file into a SQL Server XML SCHEMA COLLECTION object.
Step-by-Step Resolution Guide
Step 1: Identify the Offending Schema File
- Locate the specific
.xsdfile being imported viaCREATE XML SCHEMA COLLECTIONorALTER XML SCHEMA COLLECTION. - Search the file for the exact string:
<xs:restriction base="xs:QName">. - Note the parent element name, as this is usually tied to a custom namespace import (common in WS-Addressing or SOAP-based schemas).
Step 2: Modify the XSD to Remove the Restriction
- Open the
.xsdfile in a text editor (Notepad++ or VS Code recommended on Windows 11/Server 2025). - Change the restrictive type definition to a direct
xs:QNamereference instead of a restricted simple type. - Example fix:
- Before:
<xs:simpleType name="CustomQName"><xs:restriction base="xs:QName"/></xs:simpleType> - After: Replace all usages of
CustomQNamedirectly withxs:QNamein the parent elements, and delete thesimpleTypeblock entirely. - Save the file with UTF-8 encoding to avoid parser conflicts.
Step 3: Re-import the Corrected Schema Collection
- Open SQL Server Management Studio (SSMS) connected to your SQL Server 2025 instance.
- Drop the existing broken collection if it partially registered:
DROP XML SCHEMA COLLECTION [dbo].[YourCollectionName]; - Re-run the creation script pointing to the updated
.xsdfile:CREATE XML SCHEMA COLLECTION [dbo].[YourCollectionName] AS N'<paste corrected XSD content here>';
Step 4: Validate SQL Server Service Health
- Since this error can sometimes surface alongside resource constraints on Windows Server 2025, restart the SQL Server service via
services.mscto clear any cached schema validation locks. - Check the SQL Server Error Log (
C:\Program Files\Microsoft SQL Server\MSSQL17.MSSQLSERVER\MSSQL\Log\ERRORLOG) for secondary parsing errors that might indicate file encoding issues.
Alternative or Verification Steps
- Run
SELECT * FROM sys.xml_schema_collections WHERE name = 'YourCollectionName';to confirm the schema registered successfully without throwing Error 2276. - If modifying the XSD is not feasible (e.g., third-party vendor schema), bypass strict XML typing by storing the data in an
NVARCHAR(MAX)column instead of a typedXMLcolumn, and validate the XML manually at the application layer using .NET’sXmlReaderbefore insertion.