Link to home
Start Free TrialLog in
Avatar of mmalik15
mmalik15

asked on

how to create a hierarchical data tree from a table

I have a table which has related terms. By related terms I mean a term can have a broader term and a narrower term. See attached image for more clarification. I have a table called Relation in my database. The table has fields like Id, maintermid, relatedtermid, relationshiptypeid(say 1 for BT, 2 for NT). I run recursive queries to find all the narrower terms for a given term and similarly run recursive queries to find broader terms. My requirement is now to create a web service and send a hierarchical tree as in the attached image. I know how to develop a service but wondering how can I organize my data as a tree to send it via web service.
hireachy.png
Avatar of Barry Cunney
Barry Cunney
Flag of Ireland image

USE FOR XML with a SELECT to output XML and send the XML to the web service

http://www.simple-talk.com/sql/learn-sql-server/using-the-for-xml-clause-to-return-query-results-as-xml/
ASKER CERTIFIED SOLUTION
Avatar of Meir Rivkin
Meir Rivkin
Flag of Israel image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial