Please start any new threads on our new site at https://forums.sqlteam.com. We've got lots of great SQL Server experts to answer whatever question you can come up with.

 All Forums
 SQL Server 2008 Forums
 Transact-SQL (2008)
 Flatten Recursive Hierarchy

Author  Topic 

swain
Starting Member

1 Post

Posted - 2012-03-27 : 05:04:24
Hi,

I have a table with columns
ChildID, ParentID, Amount,

I would like to transform it to

Level, ChildID, Amount where eg "level 1" is the first Child Parent relationship. Any help I'll appreciate.

Thanks

visakh16
Very Important crosS Applying yaK Herder

52326 Posts

Posted - 2012-03-27 : 12:06:39
you will need to use common table expression
see

http://msdn.microsoft.com/en-us/library/ms186243.aspx

------------------------------------------------------------------------------------------------------
SQL Server MVP
http://visakhm.blogspot.com/

Go to Top of Page
   

- Advertisement -