SQL Server 2008 R2: Only get NULL when using XQuery (.value) to query into XML

My table is called Table_1 with 2 columns: id (int) and myxml (xml)

I attached the xml snapshot I am working with below.
(This xml corresponded to id = 1)

The problem I have is that I only get NULL when using XQuery (.value) to query into this XML

This is the code I wrote:

SELECT myXml.value(‘(Archivebatch/Cr/Modifcltn/Modif)[2]/@modiftype’.’int’)
from Table_1 where id = 1

I only get NULL no matter what I tried to query out of the xml
I have also try including namespace which doesn’t help (still only return NULL)

http://i57.tinypic.com/21eztbm.png


Source: xml

Leave a Reply