Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7968025
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 4, 20262026-06-04T07:00:45+00:00 2026-06-04T07:00:45+00:00

SQL Server 2008 allows us to validate XML against an existing XML Schema Collection

  • 0

SQL Server 2008 allows us to validate XML against an existing XML Schema Collection by defining a typed XML column/variable: DECLARE @TypedXml XML(MyXmlSchemaCollection)

However, as far as I can see, the XML Schema Collection has to be known at the time we define the column/variable.

Is there a way to validate XML using an XML schema specified at runtime?

For example:

DECLARE @Xml XML
SET @Xml = 
N'<person>
    <firstname>Ming</firstname>
    <lastname>The Merciless</lastname>
</person>'

DECLARE @Xsd XML
SET @Xsd =
N'<?xml version="1.0"?>
<xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema">
 <xs:element name="person">
  <xs:complexType>
    <xs:sequence>
      <xs:element name="firstname" type="xs:string"/>
      <xs:element name="lastname" type="xs:string"/>
      <xs:element name="dateofbirth" type="xs:date"/>
    </xs:sequence>
  </xs:complexType>
 </xs:element>
</xs:schema>'

DECLARE @Valid BIT
SET @Valid = (SELECT dbo.f_ValidateXmlAgainstXsd(@Xml, @Xsd)) -- With a user-defined function?
EXEC @Valid = s_ValidateXmlAgainstXsd @Xml, @Xsd -- With a stored procedure?
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-04T07:00:45+00:00Added an answer on June 4, 2026 at 7:00 am

    For your kind of requirement I would probably explore CLR integration: using stored procedures or user defined functions; you should check first if in your environment, CLR integration is something that’s allowed.

    It would be too much to post here; however, the code to validate an XML document using .NET is common; and the links I’ve added to the online books for SQL Server will be there as long as SQL 2008 will be around…

    In general, I believe that to implement a validation that’s not limited by how XSD is supported on SQL Server, one should rely on CLR integration. The limitations in XSD collections on SQL server as described here could swing many people in this direction anyway. There are some issues to figure out in a high volume environment, caching of compiled XSDs being the most important one in my mind. The other one is the complexity of the XSDs, and how the XSDs are sourced and referenced (include/import/redefine support). Trying to implement yourself these aspects would give you for sure an appreciation as to why xsd:include is not supported by SQL Server…

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Are there any updates in SQL Server 2008 to allow a variable for the
This is for (MS SQL Server 2008) It allows the user to schedule other
Is it only SQL Server 2008 that allows you to pass a nullable type
I want create a role in SQL server 2008, which will allows specific group
Does anyone know if the 2008 Developer edition of SQL Server allows you to
i declared a column as numeric(5,3) in sql server 2008 exp r2 and i
I'm using SQL Server 2008. I have a NVARCHAR(MAX) column called Title and i
SQL Server 2005/2008, db=user=schema=owner='John', ASP.net 2.0.50727, vb, IIS7 I'm moving website from one server
Using SQL Server 2008, is there a way to allow inserts to a table
SQL Server 2008 Profiler always profiles all databases. I want to restrict profiling or

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.