Transact-SQL
A Microsoft extension to the ANSI SQL language that includes procedural programming, local variables, and various support functions.
4,665 questions
This browser is no longer supported.
Upgrade to Microsoft Edge to take advantage of the latest features, security updates, and technical support.
I have a table where parent child relation maintain by ID and ParentID.
Now how could i display the Parent Child Data hierarchy. where Parent will come then its child will be shown.
Top Most Parent has 0 value in ParentID field.
Please discuss with a example
Thanks
Hello,
For this you can use a recursive CTE (common table expression), see
WITH common_table_expression (Transact-SQL)
=> Guidelines for Defining and Using Recursive Common Table Expressions
=> Example D. Using a recursive common table expression to display multiple levels of recursion