From the course: Microsoft SQL Server 2016 Essential Training

Unlock this course with a free trial

Join today to access over 25,300 courses taught by industry experts.

Shred XML

Shred XML

- [Instructor] Now we'll look at using SQL Server 2016 to convert XML data into data stored in columns and rows. This process is sometimes called shredding XML, so we shred XML into a tabular format. In other words, something that looks like a table. I've staged some code for you for this. I'll copy and paste all of that into a new query window. At the top, there's two lines that declare variables. The variable rawXML will be used to hold the unprocessed XML. Then the variable XML inMemory will be used to hold the formatted data in memory after it's been shredded. I then have some lines where I'm creating some XML. I just have the XML inline in the script. This also could read XML from a file, read XML from a table, or use just about any other source of XML. Then I'm going to call a stored procedure that's built-in. It's called sp_xml_preparedocument. It takes one input, and that is the rawXML and produces one output,…

Contents