troubleshooting Question

For XML PATH Querying

Avatar of dazkraz
dazkraz asked on
Microsoft SQL Server 2005Microsoft SQL Server 2008
11 Comments1 Solution1100 ViewsLast Modified:
We have a table with three columns "ID" int, "ParentID" int (foreign key to itself), "Data" XML type.

This data is contained in the table:
1,  null,  "<kitchenware><name>Kitchenware</name></kitchenware>"
2,  1,  "<product><name>Knife</name></product>"
3,  1,  "<product><name>SuperKnife</name></product>"
4,  3,  "<product><name>SuperKnife Replacement Blade</name></product>"

How do I being the data back using SQL Server 2008 XML to look like:
<kitchenware>
  <name>Kitchenware</name>
  <product>
    <name>Knife</name>
  </product>
  <product>
    <name>SuperKnife</name>
    <product>
      <name>SuperKnife Replacement Blade</name>
    </product>
  </product>
</kitchenware>
Join the community to see this answer!
Join our exclusive community to see this answer & millions of others.
Unlock 1 Answer and 11 Comments.
Join the Community
Learn from the best

Network and collaborate with thousands of CTOs, CISOs, and IT Pros rooting for you and your success.

Andrew Hancock - VMware vExpert
See if this solution works for you by signing up for a 7 day free trial.
Unlock 1 Answer and 11 Comments.
Try for 7 days

”The time we save is the biggest benefit of E-E to our team. What could take multiple guys 2 hours or more each to find is accessed in around 15 minutes on Experts Exchange.

-Mike Kapnisakis, Warner Bros