How to query xml value inside a xml column in SQL server

twissereuggiz

New Member
I have something like following code inside [XMLValue] column of a table called "AlgorithmLog": \[code\]<?xml version="1.0" encoding="utf-8"?><AdapterInfo xmlns:i="http://www.w3.org/2001/XMLSchema-instance" xmlns:d1p1="http://schemas.datacontract.org/2004/07/Adapters.Adapter.CloudTrader" xmlns="http://schemas.datacontract.org/2004/07/Adapters.Adapter" i:type="d1p1:AlgorithmStatusReport"> <SequenceNumber>0</SequenceNumber> <TrackingGuid i:nil="true" /> <d1p1:Broker>Default</d1p1:Broker> ... <d1p1:XMLValue><?xml version="1.0"?><int xmlns="http://schemas.microsoft.com/2003/10/Serialization/">1900</int></d1p1:XMLValue></AdapterInfo>\[/code\]and I want to get the value "1900" inside the node \[code\]<d1p1:XMLValue>\[/code\]So here is my query:\[code\]WITH XMLNAMESPACES('http://schemas.datacontract.org/2004/07/Adapters.Adapter' AS x, 'http://schemas.datacontract.org/2004/07/Adapters.Adapter.CloudTrader' As p, 'http://schemas.microsoft.com/2003/10/Serialization/'as w) SELECT XMLValue.query('(/x:AdapterInfo/p:XMLValue/w:int)[1]')AS [XMLVaule] FROM AlgorithmLog \[/code\]But it returns nothing.Could anyone tell me where I did wrong or how I can do it?Thank you.
 
Back
Top