我正在尝试使用FOR XML AUTO生成XML,我没有得到预期的XML格式。
SELECT OMR.RIDER_NAME AS RiderName,
/*CHANGES MADE FOR PWR RIDER DETAILS BINDING IN CPF FORM*/
CASE WHEN ORD.FK_RIDER_ID IN ('1','2') THEN ORD.DHCB_RIDER_AMOUNT ELSE ORD.SUM_ASSURED END AS SumAssured,
CASE WHEN ORD.FK_RIDER_ID IN ('1','2') THEN ORD.DHCB_RIDER_TERM ELSE ORD.POLICY_BENEFIT_PERIOD END AS PolicyBenefitPeriod,
CASE WHEN ORD.FK_RIDER_ID IN ('1','2') THEN ORD.DHCB_RIDER_TERM ELSE ORD.PREMIUM_PAYMENT_TERM END AS PremiumPaymentTerm
FROM RD ORD INNER JOIN RM OMR ON OMR.PK_RIDER_ID = ORD.FK_RIDER_ID
WHERE ORD.FK_QUOTATION_ID = 78027
FOR XML AUTO , ROOT('RIDER')
我的格式低于xml格式
<RIDER>
<OMR RiderName="Test" SumAssured="0.00" PolicyBenefitPeriod="15" PremiumPaymentTerm="1" />
<OMR RiderName="Test1" SumAssured="0.00" PolicyBenefitPeriod="15" PremiumPaymentTerm="1" />
</RIDER>
我希望xml采用以下格式
<RIDER>
<OMR RiderName="test">
<ORD SumAssured="0" PolicyBenefitPeriod="15" PremiumPaymentTerm="0" />
</OMR>
<OMR RiderName="test">
<ORD SumAssured="0" PolicyBenefitPeriod="15" PremiumPaymentTerm="0" />
</OMR>
</RIDER>