Hi,
I have a column named "XMLColumnwhich" in a Table named "demandRequest"contains an XML as follows
<RequestEntity xmlns:i="http://www.w3.org/2001/XMLSchema-instance" xmlns="explorer/contact/2011/03/">
<Checked>false</Checked>
<Items>
<ItemEntity>
<Checked>true</Checked>
<FromDate>2013-10-01T00:00:00</FromDate>
<Id1>604395</Id1>
<Id2>11278003</Id2>
<Option>Random1</Option>
<ToDate>2013-11-01T00:00:00</ToDate>
</ItemEntity>
<ItemEntity>
<Checked>true</Checked>
<FromDate>2013-07-01T00:00:00</FromDate>
<Id1>604394</Id1>
<Id2>11277949</Id2>
<Option>Random1</Option>
<ToDate>2013-08-01T00:00:00</ToDate>
</ItemEntity>
</Items>
<EmailNotification>1</EmailNotification>
<EndDate>2013-11-01T00:00:00</EndDate>
<Level>crossing</Level>
<LineNumber i:nil="true" />
<id1>0</id1>
<id2 i:nil="true" />
<Version>0</Version>
</RequestEntity>
I would like to get the value of all id1, i tried following but getting NULL as response
SELECT CAST(XMLColumn as xml).value('(/RequestEntity/Items/ItemEntity/Id2/text())[1]', 'varchar(50)') AS P
FROM [demandRequest];
Can you kindly help me here to find out what is the correct way.
Thanks