我有如下的xml代码,我想获得“processEngine - > id”如何使用sql获取
"<?xml version="1.0" encoding="UTF-8"?>
<processEngine id="5077000" instanceName="bg2-dev.excers">
<controller heartBeat="2014-10-27T15:59:50"/>
<loader heartBeat="2014-10-27T16:01:00" queueLength="62"/>
<conditionWaitList queueLength="52"/>
<retryWaitList queueLength="0"/>
<actionWaitList queueLength="0"/>
<PreConditionPipelineManager load="1.463905239430332E-6" noOfPipelines="5" queueLength="0"
recentLoad="1.1947981003500136E-5">
<pipeline heartBeat="2014-10-27T16:01:01" index="4" load="7.216747673537921E-6"
name="Pre Condition Pipeline 0"
recentLoad="5.963712649181781E-5"
runTime="6811"
running="false"
startTime="2014-10-16T17:59:18"/>
</processEngine>"
提前致谢.......
答案 0 :(得分:1)
试试这个 -
DECLARE @temp1 XML
SELECT @temp1 = '<?xml version="1.0" encoding="UTF-8"?>
<processEngine id="5077000" instanceName="bg2-dev.excers">
<controller heartBeat="2014-10-27T15:59:50" />
<loader heartBeat="2014-10-27T16:01:00" queueLength="62" />
<conditionWaitList queueLength="52" />
<retryWaitList queueLength="0" />
<actionWaitList queueLength="0" />
<pipeline heartBeat="2014-10-27T16:01:01" index="4" load="7.216747673537921E-6" name="Pre Condition Pipeline 0" recentLoad="5.963712649181781E-5" runTime="6811" running="false" startTime="2014-10-16T17:59:18" />
</processEngine>'
SELECT
a.b.value('@id', 'varchar(10)') value
FROM
@temp1.nodes('/processEngine') a(b)