select grandparentname, parentname, foldername, number, procid, sectnum, secttitle, sectionstart, xsection.value('@OriginalSteps', 'char(1)') OriginalSteps from
(select t1.*, cc.number sectnum, cc.text secttitle, cast(cc.config  as xml) xconfig from 
(select grandparentname, parentname, foldername, number, procid, xprocedure.value('@SectionStart', 'int') sectionstart from 
(select number, cc.contentid, itemid procid,  cast(config as xml) xconfig from contents cc
join items ii on ii.contentid = cc.contentid where type = 0) t1
outer apply xconfig.nodes('//Procedure') tprocedure(xprocedure)
join vefn_getversionitems('') vi on vi.contentid = t1.contentid
join vefn_getversionnames() vn on vn.versionid = vi.versionid) t1
left join items ii on ii.itemid = t1.sectionstart
left join contents cc on cc.contentid = ii.contentid
where sectionstart is not null) t1
cross apply xconfig.nodes('//Section') tsection(xsection)