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
hireachy.png
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
http://www.simple-talk.com/sql/learn-sql-server/using-the-for-xml-clause-to-return-query-results-as-xml/