SQL SERVER – Tips from the SQL Joes 2 Pros Development Series – Shredding XML – Day 33 of 35

Answer simple quiz at the end of the blog post and –

Every day one winner from India will get Joes 2 Pros Volume 5.

Every day one winner from United States will get Joes 2 Pros Volume 5.

Shredding XML

Our introduction to XML in the last 3 days of posts thus far has focused on seeing tabular data taken from SQL Server and streamed into well-formed XML instead of the rowset data we typically work with.  The next two posts will focus on the reverse process.  Our starting point will be data which is already in XML and which we will turn into table data, or which we will query in order to answer questions.

Our previous posts focused on streaming data into XML and we produced XML using the modes Raw, Auto, and Path. We used familiar data from the JProCo database (Employee, Location, Grant, and Customer data).  We refined and manipulated our XML queries in order for the XML result to appear according to our precise specifications.

SQL SERVER - Tips from the SQL Joes 2 Pros Development Series - Shredding XML - Day 33 of 35 j2p_33_1

Operations which parse and consume XML data are known collectively by the term shredding XML. The next few posts will focus on the steps to prepare an XML stream so you can turn it into a table or some other tabular result set. XML is case-sensitive so in order for your examples and exercises to run properly be sure that your XML fragments precisely match the figures with respect to uppercase and lowercase.

Consuming XML

Anytime you turn XML into another data format (e.g., into a SQL Server table) that process is called shredding XML. Before you can shred your XML, you must first prepare it. Preparing XML for SQL means storing the XML in a memory space where a query can retrieve and make use of the data. SQL Server 2008 provides native XML support to make streaming and shredding XML more robust.

SQL SERVER - Tips from the SQL Joes 2 Pros Development Series - Shredding XML - Day 33 of 35 j2p_33_2

Think of XML as a big meal for SQL. While we essentially added just one line of code to our Select query to turn tabular data into an XML document, going the other direction is more complex. Behind the scenes, SQL Server uses additional memory when consuming XML. Our preparation will include a step to parse and store the XML document in memory. And the same way a big feast requires additional cleanup, we must include a step to remove the XML document from the memory cache once it is no longer needed.

Now that we understand the essential rules and components of well-formed XML documents, we will turn our attention toward consuming XML data. In the next posts we will see an advanced method (nodes) for shredding XML. Right now we want you to be familiar with the terms used when going back and forth from SQL to XML.

SQL SERVER - Tips from the SQL Joes 2 Pros Development Series - Shredding XML - Day 33 of 35 j2p_33_3

Note: If you want to setup the sample JProCo database on your system you can watch this video. For this post you will want to run the SQLInteropChapter1.0Setup.sql script from Volume 5.

Question 33

What process will transform XML data to a rowset?

  1. Shredding
  2. Retrieving

Rules:

Please leave your answer in comment section below with correct option, explanation and your country of resident.
Every day one winner will be announced from United States.
Every day one winner will be announced from India.
A valid answer must contain country of residence of answerer.
Please check my facebook page for winners name and correct answer.
Every day one winner from India will get Joes 2 Pros Volume 5.
Every day one winner from United States will get Joes 2 Pros Volume 5.
The contest is open till next blog post shows up at which is next day GTM+2.5.

Reference:  Pinal Dave (https://blog.sqlauthority.com)

Joes 2 Pros, SQL Scripts
Previous Post
SQLAuthority News – Programming & Development For Microsoft SQL Server 2008
Next Post
SQL SERVER – Tips from the SQL Joes 2 Pros Development Series – Preparing XML in Memory – Day 34 of 35

Related Posts

67 Comments. Leave new

  • Partha Pratim Dinda
    September 2, 2011 10:35 am

    Ans: 1.shredding

    Operations which parse and consume XML data are known collectively by the term shredding XML.

    Partha,
    India

    Reply
  • Nakul Vachhrajani
    September 2, 2011 10:39 am

    Correct answer is #1 – Shredding.

    These series of posts on XML are nothing short of a goldmine of introductory learning material. Excellent stuff!

    Country of residence: India

    Reply
  • vishal patwardhan (@vishalpatwardha)
    September 2, 2011 10:43 am

    Correct Option is #1

    Explanation :
    The Process of Parsing the xml and load it into sql table is called xml shredding,for which we should focus on case sensitivity of xml elements with sql columns and need to store it into cache.

    Vishal Patwardhan
    Indore(India)

    Reply
  • Geetanjali Agarwal
    September 2, 2011 10:43 am

    Correct Answer is 1.

    1. Shredding

    Anytime you turn XML into another data format (e.g., into a SQL Server table) that process is called shredding XML or in other words Operations which parse and consume XML data are known collectively by the term shredding XML.

    Streaming – Converting SQL Server Table Data into XML Format.
    Shredding – Converting XML Data into SQL Server Tabular Result Set.

    Thanks,
    Geetanjali Agarwal
    India, Noida

    Reply
  • tej narayan maurya
    September 2, 2011 10:51 am

    option one is correct that is shredding

    new delhi(india)

    Reply
  • Answer is option 1> Shredding

    Madhusmita (India)

    Reply
  • Kewal Krishan Khanna
    September 2, 2011 11:00 am

    Correct answer is option 1.

    When we convert the xml data into another format the term is called Shredding.

    When we convert the data in sql server table into xml format that term is called Streaming.

    India

    Reply
  • Hi

    Correct ans is 1st Shredding,

    Because to transfer xml data into another data format is known as shredding.

    I am from india.

    Reply
  • Correct answer is option 1:
    1.Shredding

    City: Baroda
    Country: India

    Thanks
    GurjitSingh

    Reply
  • Correct answer is Option #1, Shredding

    The process that turn XML into another data format (e.g., into a SQL Server table) is called shredding XML.

    Reply
  • Correct answer is Option #1, Shredding

    The process that turn XML into another data format (e.g., into a SQL Server table) is called shredding XML.

    SIJIN KUMAR V P
    INDIA

    Reply
  • Hi

    The correct answer is option 1) Shredding

    XML shredding is the process of consuming XML data and parsing out the content to scalar elements.

    WE can use nodes() to achieve this.
    And if the data is huge, to improve the performance – having typed the XML using a schema and created an XML Index will give a performance improvement.

    Thanks & Regards
    Santosh.S
    Bangalore,India

    Reply
  • Hi,
    As description given “Anytime you turn XML into another data format (e.g., into a SQL Server table) that process is called shredding XML.”

    #Option 1 is the correct Answer “Shredding”.

    Thanks…
    Rajneesh Verma
    (INDIA)

    Reply
  • The correct answer is:
    1. Shredding

    Sudeepta,
    India.

    Reply
  • The correct answer is #1 – Shredding.

    Deepali Bhende
    INDIA

    Reply
  • Shredding is the right answer.

    Richa,
    USA

    Reply
  • The correct option is 1.Shredding

    (Sale, Nigeria )

    Reply
  • Option 1

    1.Shredding

    Country:India

    Reply
  • Hi Sir,

    Option 1 Shredding is the right answer

    As said in the blog above “Operations which parse and consume XML data are known collectively by the term shredding XML”
    shredding refers to extracting relevant data out of hierarchical XML and putting it into flat relational storage.

    Regards,
    P.Anish Shenoy,
    INDIA, Bangalore, Karnataka

    Reply
  • The correct answer is:
    1. Shredding

    Hiren Bavishi
    India.

    Reply

Leave a Reply