MSSQL validate an xml field agains an xsd file

Posted on 2012-08-15
Last Modified: 2012-09-06
Can someone show me how to validate a xml field against a
xsd file (or prefered an xsd in a field)
Question by:pucko73
    LVL 29

    Expert Comment

    by:Rich Weissler
    I'll start with an apology.  When it comes to xml, I'm still learning and haven't had occasion to use anything I've learned on the topic quite yet.  So, use that as salt to flavor the following:

    I believe the XSD is imported/registered with SQL with the CREATE XML SCHEMA COLLECTION.  Once the XML schema is created, you can create TYPED XML objects, which are validated against the schema. gets into the differences, and was a little easier to follow than anything I'd read previously.

    I've tossed The Art of XSD: SQL Server XML Schema Collections on my Kindle, but haven't read it yet.
    LVL 14

    Accepted Solution

    so you want to create typed xml column.
    for that you have to first create xml schema collection.
    <schema xmlns="">
          <element name="root" type="string"/>
    CREATE TABLE T (Col1 xml (mySC))

    Open in new window


    Featured Post

    Enabling OSINT in Activity Based Intelligence

    Activity based intelligence (ABI) requires access to all available sources of data. Recorded Future allows analysts to observe structured data on the open, deep, and dark web.

    Join & Write a Comment

    Everyone has problem when going to load data into Data warehouse (EDW). They all need to confirm that data quality is good but they don't no how to proceed. Microsoft has provided new task within SSIS 2008 called "Data Profiler Task". It solve th…
    JSON is being used more and more, besides XML, and you surely wanted to parse the data out into SQL instead of doing it in some Javascript. The below function in SQL Server can do the job for you, returning a quick table with the parsed data.
    Using examples as well as descriptions, and references to Books Online, show the documentation available for datatypes, explain the available data types and show how data can be passed into and out of variables.
    Viewers will learn how to use the UPDATE and DELETE statements to change or remove existing data from their tables. Make a table: Update a specific column given a specific row using the UPDATE statement: Remove a set of values using the DELETE s…

    755 members asked questions and received personalized solutions in the past 7 days.

    Join the community of 500,000 technology professionals and ask your questions.

    Join & Ask a Question

    Need Help in Real-Time?

    Connect with top rated Experts

    16 Experts available now in Live!

    Get 1:1 Help Now