1
我有一個XML formatted like this:查詢XML在SQL Server
<Maximum.Edm.CodeIncludedInCalculation >
<CalculationsByProvince>
<Maximum.Edm.IncludedInByProvince Province="QC">
<RevenueCodeCalculations CalculationListType="RevenueCode">
<Maximum.Edm.CalculationIncluded Code="@Vacation" IsSelected="True" />
<Maximum.Edm.CalculationIncluded Code="@RRQ" IsSelected="True" />
<Maximum.Edm.CalculationIncluded Code="@EmploymentInsurance" IsSelected="True" />
[...]
</RevenueCodeCalculations>
<TaxableBenefitCalculations CalculationListType="TaxableBenefits">
<Maximum.Edm.CalculationIncluded Code="1" IsSelected="False" />
<Maximum.Edm.CalculationIncluded Code="AV. VIE FE" IsSelected="True" />
</TaxableBenefitCalculations>
<DeductionCodeCalculations CalculationListType="DeductionCode">
<Maximum.Edm.CalculationIncluded Code="123" IsSelected="False" />
<Maximum.Edm.CalculationIncluded Code="456" IsSelected="True" />
<Maximum.Edm.CalculationIncluded Code="AC" IsSelected="False" />
[...]
</DeductionCodeCalculations>
</Maximum.Edm.IncludedInByProvince>
<Maximum.Edm.IncludedInByProvince Province="ON">
[...]
</Maximum.Edm.IncludedInByProvince>
</CalculationsByProvince>
</Maximum.Edm.CodeIncludedInCalculation>
我想創建一個簡單的查詢將返回各CalculationIncluded
與code
和IsSelected
值。我的最終目標是創建一個存儲過程,該存儲過程將收到code
,province
和CalculationListType
並返回IsSelected
值。
我試圖用從here,here和here的例子,但我不斷收到null
或空值。
查詢我試着用的例子之一進行:
select * from
(select
pref.value('(text())[1]', 'varchar(32)') as RoleName
from
Payroll.RevenueCode CROSS APPLY
IncludeInCalculation.nodes('/Maximum.Edm.CodeIncludedInCalculation/CalculationsByProvince/Maximum.Edm.IncludedInByProvince/RevenueCodeCalculations') AS IncludeInCalculation(pref)
) as Result
該作品頂尖 !!非常感謝 –
男孩我誤解了問題+1 –