How to query for Xml values and attributes from table in SQL Server -



How to query for Xml values and attributes from table in SQL Server -

i have xml code below,i want "processengine -> id" how can using 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 status pipeline 0" recentload="5.963712649181781e-5" runtime="6811" running="false" starttime="2014-10-16t17:59:18"/> </processengine>"

thanks in advance.......

try -

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 status 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 @temp1.nodes('/processengine') a(b)

sql-server xml

Comments

Popular posts from this blog

xslt - DocBook 5 to PDF transform failing with error: "fo:flow" is missing child elements. Required content model: marker* -

mediawiki - How do I insert tables inside infoboxes on Wikia pages? -

Local Service User Logged into Windows -