- FOR XML RAW
- FOR XML AUTO
- FOR XML PATH
When you use FOR XML AUTO, the source table and columns become elements in the output. The column order determines the nesting of elements in the output.
When you use FOR XML PATH, you use XPath to define the elements and attributes in the output.
If you need to go the other way around, and insert data into the database from an XML document source, then you will be doing "shredding". You make use of the OPENXML function. You will use the DOM to reference data. The translation from DOM nodes to database rows is defined using XPath.