I know there have been several forum discussions about flattening hierarchies using recursive CTEs but the examples I have found have a ParentID field in the data. My data does not have this.
Please take a look at this sample code
declare @table table
insert into @table
select 'DP961A1111', 1, 'LevelDesc1'
select 'DP961A1111', 2, 'LevelDesc2'
select 'DP961A1111', 3, 'LevelDesc3'
select * from @table
--I need to display the results like this:
select 'DP961A1111' as id, 'LevelDesc1' as LevelDesc1, 'LevelDesc2' as LevelDesc2, 'LevelDesc3' as LevelDesc3
Can you guys help?