select ff.formatID,ff.Name,ff.Description--,ff.Data --,pf.formatID,pf.Name,pf.Description --,gf.formatID,gf.Name,gf.Description , isnull(ffxStpSectLayData.value('@CompressSteps','varchar(5)'),isnull(pfxStpSectLayData.value('@CompressSteps','varchar(5)'),gfxStpSectLayData.value('@CompressSteps','varchar(5)'))) CompressSteps , isnull(ffxStpSectLayData.value('@PartialStepCompression','varchar(5)'),isnull(pfxStpSectLayData.value('@PartialStepCompression','varchar(5)'),gfxStpSectLayData.value('@PartialStepCompression','varchar(5)'))) PartialStepCompression from Formats FF Join Formats PF on PF.FormatID = ff.ParentID Join Formats GF on GF.FOrmatID = PF.ParentID cross apply ff.Data.nodes('//StpSectLayData') fftStpSectLayData(ffxStpSectLayData) cross apply pf.Data.nodes('//StpSectLayData') pftStpSectLayData(pfxStpSectLayData) cross apply gf.Data.nodes('//StpSectLayData') gftStpSectLayData(gfxStpSectLayData) order by ff.formatID