--Select * from( SELECT FormatID, Name, Description ,v.query('.') FontNode ,v.query('..') ParentNode --,v.value('../@Index', 'INT') AS [Index] ,v.value('../@Type', 'varchar(100)') AS Type ,v.value('../@ParentType', 'varchar(100)') AS ParentType ,v.value('@Family', 'varchar(30)') AS FontFamily ,v.value('@Size', 'INT') AS FontSize ,v.value('@Style', 'varchar(100)') AS FontStyle ,case when v.exist('../../Step') = 1 then 'Step' when v.exist('../../FormatData') = 1 then 'FormatData' when v.exist('../../TabData') = 1 then 'TabData' when v.exist('../../SectionHeader') = 1 then 'Section Header' when v.exist('../../Separator') = 1 then 'Separator' when v.exist('../../Item') = 1 then 'Item' when v.exist('../../Continue') = 1 then 'Continue' when v.exist('../../End') = 1 then 'End' when v.exist('../../DocStyle') = 1 then 'DocStyle' when v.exist('../../Box') = 1 then 'Box' when v.exist('../../CheckOffHeader') = 1 then 'CheckOffHeader' when v.exist('../../TableOfContentsData') = 1 then 'TableOfContentsData' when v.exist('../../TopOfPage') = 1 then 'TopOfPage' else null end FontFor FROM Formats CROSS APPLY Data.nodes('//Font') TempXML(v) --CROSS APPLY Data.nodes('//Step/Font') TempXML(v) --CROSS APPLY Data.nodes('//FormatData/Font') TempXML(v) --order by FormatID, v.value('../@Index', 'INT') --) t1 where FontFor is null