Published on

August 13, 2011

Understanding XML Shredding in SQL Server

Welcome to our blog post on understanding XML shredding in SQL Server! In our previous articles, we explored the process of streaming data from SQL Server into XML. Today, we will focus on the reverse process – shredding XML data and turning it into table data or querying it to answer questions.

Before we dive into the details, let’s quickly recap what we’ve learned so far. We used the JProCo database and explored different modes (Raw, Auto, and Path) to produce well-formed XML from tabular data. We refined and manipulated our XML queries to meet our specific requirements.

Now, let’s move on to the concept of shredding XML. Shredding XML refers to the operations that parse and consume XML data. When we want to convert XML into another data format, such as a SQL Server table, we need to shred the XML first. But before we can do that, we need to prepare the XML.

Preparing XML for SQL Server involves storing the XML in a memory space where it can be retrieved and used by queries. SQL Server 2008 provides native XML support, making the process of streaming and shredding XML more robust. Think of XML as a big meal for SQL Server – it needs to be properly prepared before it can be consumed.

When consuming XML, SQL Server uses additional memory. We need to parse and store the XML document in memory. And just like cleaning up after a big feast, we must remove the XML document from the memory cache once it is no longer needed.

Now that we have a good understanding of the essential rules and components of well-formed XML documents, let’s focus on consuming XML data. In our upcoming articles, we will explore an advanced method called “nodes” for shredding XML. But for now, let’s familiarize ourselves with the terms used when working with XML in SQL Server.

If you want to follow along with our examples, you can set up the sample JProCo database on your system by running the SQLInteropChapter1.0Setup.sql script from Volume 5.

Quiz Question

What process will transform XML data into a rowset?

  1. Shredding
  2. Retrieving

Please leave your answer in the comment section below along with the correct option, explanation, and your country of residence. Every day, one winner from the United States and one winner from India will be announced. The winners will receive a copy of Joes 2 Pros Volume 5.

The contest is open until the next blog post is published, which will be the next day GTM+2.5.

Thank you for reading our blog post on understanding XML shredding in SQL Server. Stay tuned for more articles on SQL Server concepts and ideas!

Click to rate this post!
[Total: 0 Average: 0]

Let's work together

Send us a message or book free introductory meeting with us using button below.