I wonder how can i read a xml data and transform it to a table in TSQL?
For example:
<row>
<IdInvernadero>8</IdInvernadero>
<IdProducto>3</IdProducto>
<IdCaracteristica1>8</IdCaracteristica1>
<IdCaracteristica2>8</IdCaracteristica2>
<Cantidad>25</Cantidad>
<Folio>4568457</Folio>
</row>
<row>
<IdInvernadero>3</IdInvernadero>
<IdProducto>3</IdProducto>
<IdCaracteristica1>1</IdCaracteristica1>
<IdCaracteristica2>2</IdCaracteristica2>
<Cantidad>72</Cantidad>
<Folio>4568457</Folio>
</row>
To
8 3 8 8 25 4568457
3 3 1 2 72 4568457
If you have deeply nested XML documents (or json, html, sql) with recursive nodes (node 'folder' in node 'folder' in node 'folder') of a mixed complex type without an XSD/DTD schema you can use the tool eXtractorONE (eXtractor.ONE). No programming needed, no Xquery, no XSLT, nearly zero configuration. No limit on size. Just point to the folder with XML documents, select your target database and run it.
This is the answer, hope it helps someone :)
First there are two variations on how the xml can be written:
1
Answer:
2.
Answer:
Taken from:
http://kennyshu.blogspot.com/2007/12/convert-xml-file-to-table-in-sql-2005.html
http://msdn.microsoft.com/en-us/library/ms345117(SQL.90).aspx
To accomplish such conversion task you may consider to use some XML mapping converting tool like XMLFox Advance. We have been using the XMLFox Advance converter for years to transform consumers XML data to SQL server tables.
Use
sp_xml_preparedocument
.For detail check: http://technet.microsoft.com/en-gb/library/ms186918.aspx
As for your question: