Storing XML in SQL 2005 XMLNS issue

Posted by Mike Mengell on Stack Overflow See other posts from Stack Overflow or by Mike Mengell
Published on 2010-05-19T15:16:59Z Indexed on 2010/05/19 15:20 UTC
Read the original article Hit count: 216

Filed under:
|
|

I'm trying to store XML in SQL 2005. I have a very simple table with an Id and a XML column.

When the XML contains the attribute xmlns my searching doesn't work.

This is my XML;

insert into XMLTest (ItemXML) values ( 
'<MessageType>
    <ItemId id="ABC" xmlns="ss" />
    <Subject>sub</Subject>
</MessageType>
')

And this is my Query;

select itemid, ItemXML.query('(/MessageType/ItemId)') from XMLTest order by ItemId desc

If I change the attribute xmlns to anything else my query works.

I don't think I know enough about XML to understand what SQL is doing with the namespace. But it must be processing it and storing it differently maybe? Anyone had this issue?

© Stack Overflow or respective owner

Related posts about Xml

Related posts about sql-server-2005