How can I read an XML file and store the data in XML to our table in SQL Server 2008?
|
|
This parse node based XML. It's different to read attributes but it isn't as common I had this lying around as a demo with 3 slightly different XPath queries
|
|||
|
|
|
I have tried it with above answer. Try it, XML:
SQL:
|
|||||
|
|
I'll just add an answer so that you know you've got another option. You can also use OPENXML to read xml data. This was the way to do it in older versions of SQL Server. It's not perfect, but it works. And it's easy to abuse :-). Just compare the plans of two identical xmls treated with XPATH queries (gbn's answer) compared to OPENXML or OPENROWSET. I will use an example from the MSDN article now, but you can get the full picture:
|
|||
|
|