• I modified your query a little....just to see the levels and the root columns and removed the dates as follows:

    ;WITH ModuleHieararchy AS (

    SELECT SModuleId, ModuleId, SMName

    ,Status

    ,ParentId

    ,0 As Level, SModuleId As Root, CAST(SModuleId AS varchar(MAX)) AS TreeOrder

    ,n=1

    ,SM1=SModuleId

    ,SM2=SModuleId

    FROM ES_SubModuleMaster

    WHERE ParentId = 0

    UNION ALL

    SELECT a.SModuleId, a.ModuleId, a.SMName

    ,a.Status

    ,a.ParentId

    ,b.Level + 1, b.Root As Root, b.TreeOrder+'/'+CAST(a.SmoduleId AS varchar(20)) AS TreeOrder

    ,n+1

    ,SM1

    ,SM2=a.SModuleId

    FROM ES_SubModuleMaster a

    JOIN ModuleHieararchy b ON a.ParentID = b.sModuleID

    )

    SELECT SModuleId, ModuleId, SMName

    ,Status

    ,ParentId

    ,Level,Root,TreeOrder

    FROM ModuleHieararchy

    ORDER BY SM1, SM2, n

    11Academic Start0011

    81Content ManagementStart1111/8

    91Content Start8211/8/9

    111Shared File ListStart8211/8/11

    121Shared File List For Faculty Start8211/8/12

    161InContentStart9311/8/9/16

    151Content Management For Parent Start1111/15

    21AdministrationStart0022

    131Alumni ListStart2122/13

    31InformationStart0033

    41Personal Information Start0044

    51School SetupStart0055

    61Sign OutStart0066

    71Welcome PageStart0077

    Following is the output that is required from the data that I posted in my last reply.....I hopw I can get it done before you for a change ;-)......thanks Dwain.

    Vinu Vijayan

    For better and faster solutions please check..."How to post data/code on a forum to get the best help" - Jeff Moden[/url] 😉