SQL XML Shredding, attributes, elements and levels

10
XML Shredding, Attributes Elements and Levels Presented by Aaron Buma

Transcript of SQL XML Shredding, attributes, elements and levels

Page 1: SQL XML Shredding, attributes, elements and levels

XMLShredding, Attributes Elements and Levels

Presented by Aaron Buma

Page 2: SQL XML Shredding, attributes, elements and levels

Session Overview

• Shredding XML• Attributes• Elements• Levels

Page 3: SQL XML Shredding, attributes, elements and levels

Shredding XML

• XML SQL SERVER Tabular Data• “XML Shredding”: extracting values from XML documents for

storage in a relational database• sp_XML_PrepareDocument – loads XML into memory– Returns plan handle

Page 4: SQL XML Shredding, attributes, elements and levels

Shredding XML

• Removing a plan from memory– sp_XML_RemoveDocument #HandleID– Closing Session (available after SQL 2000)

Page 5: SQL XML Shredding, attributes, elements and levels

Shredding XML

• OpenXML(Plan Handle, Row Pattern)– Plan Handle is the output from sp_XML_PrepareDocument – Row Pattern is the level of XML you want returned as data

Page 6: SQL XML Shredding, attributes, elements and levels

Demo

Page 7: SQL XML Shredding, attributes, elements and levels

Row and Column Patterning

• Returning matching Row Patterns: use ‘//’ notation

• Column Patterns from higher levels: use ‘../’ notation

Page 8: SQL XML Shredding, attributes, elements and levels

OpenXML Options

• With options you can define the default column type as: Attributes (1), Elements (2), Attributes and Elements (3)

• You can still define columns as Attributes or Elements if needed

Page 9: SQL XML Shredding, attributes, elements and levels

Demo

Page 10: SQL XML Shredding, attributes, elements and levels

Questions?

• Any Questions?

Contact: [email protected]

Additional Free SQL Trainings at:http://www.aaronbuma.com/category/sql-training/