DECLARE @idoc int
EXEC sp_xml_preparedocument @idoc output, '<MainElement>
<LineBusiness id="12345">
<LOBCd>WORK</LOBCd>
<RateState>
<StateProvCd>IN</StateProvCd>
<LocInfo>
<RateClass id="abc">
<RatingClassificationCd>1234</RatingClassificationCd>
<Exposure>100</Exposure>
<RatingClassificationDesc>CLASS TEST 1</RatingClassificationDesc>
</RateClass>
</LocInfo>
</RateState>
<RateState>
<StateProvCd>IL</StateProvCd>
<LocInfo>
<RateClass id="def">
<RatingClassificationCd>5678</RatingClassificationCd>
<Exposure>500</Exposure>
<RatingClassificationDesc>CLASS TEST 2</RatingClassificationDesc>
</RateClass>
</LocInfo>
</RateState>
</LineBusiness></MainElement>'
SELECT RatingClassificationCd, RatingClassificationDesc, Exposure, StateProvCd
FROM OPENXML (@idoc, '/MainElement/LineBusiness/RateState/LocInfo/RateClass', 3)
WITH (StateProvCd char(2) '../../../RateState/StateProvCd',
RatingClassificationCd char(5) 'RatingClassificationCd',
RatingClassificationDesc varchar(250) 'RatingClassificationDesc',
Exposure numeric(18,0) 'Exposure'
)
EXEC sp_xml_removedocument @idoc
|