I had been trying to help many people with SQL Server XML related questions in various forums and UG meetings and heard a lot of questions repeatedly coming up from different people. I have a few other tutorials in this web site that discuss various SQL Server XML related topics. I am trying to build one more set of tutorials that tries to answer some of the most common XML processing questions.
Based upon the questions I hear from people, I think there are 4 major XML processing requirements people usually have.
- Read values using XQuery from an XML document having a specific structure
- Create an XSD Schema for an XML document having a specific structure
- Generate an XML document having a specific structure, taking data from one or more tables
- Load data from an XML document having a specific structure, into one or more tables
Note that I have highlighted "specific structure". I talked to many people in the past who know how to perform one or more of the above operations with XML documents having a certain structure. But they find it difficult when the XML structure changes. Some people can read values from attributes, but they find it hard when the values are presented in elements. Or people can easily load data using XML Bulk Load when there are two levels of XML hierarchy, but find it hard when the structure become more complicated.
So the structure of the XML is very important. This set of tutorials aims at helping people who need help to handle XML documents with different structures. I hope this tutorial will help them to be able to process XML documents with ANY structure.
How does this Tutorial Work?
What I am trying to do in this tutorial is to present the same data in different XML structures. I have created an XML document that contains the information of a Sales Order. So far I have created 20 different representation of the same data, that results in 20 different XML documents having different structure. Then we will perform all the 4 action mentioned above, on those different XML documents. We will read information from all those documents using XQuery, Load the data to one or more Tables, create XSD schemas for those documents and see how to generate documents with different structures using FOR XML.
Tutorials in this series
- SQL Server XML Tutorials - Sample XML Documents
- SQL Server XML Tutorials - XQuery Tutorials
- SQL Server XML Tutorials - XSD Tutorials (coming soon)
- SQL Server XML Tutorials - FOR XML Tutorials (coming soon)
- SQL Server XML Tutorials - XML Bulk Load Tutorials (coming soon)
Other SQL Server XML Tutorials
- XQuery Labs - A Collection of XQuery Sample Scripts
- SQLXML Labs - A collection of SQLXML Sample Scripts