Storing XML in SQL 2005 XMLNS issue
- by Mike Mengell
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?