select itemid, contentid,foldername,location, text,xConfig, ISNULL(xSubSection.value('@Edit','varchar(1)'),'N') EditSteps from ( select itemid, vi.contentid, vn.foldername,dbo.ve_getshortpath(itemid) location, text, cast(config as xml) xConfig from vefn_getVersionItems('') VI join vefn_getversionnames() VN ON vn.versionid =vi.versionid join contents CC ON CC.Contentid = vi.contentid Where VI.ContentID in(Select ContentID from Parts where FromType = 2) -- Sections And VI.ContentID in(Select ContentID from Parts where FromType = 6) -- Steps ) AH outer apply xConfig.nodes('//SubSection') tSubSection(xSubSection) --where xSubSection.value('@Edit','varchar(1)') is not null