This problem is really nasty it seems. I have the following small XML in a column named, "Message", and I'd like to query against it. The problem I'm having is with the "ClaimData" element. As you can see, it sets its namespace to an empty string.
<DataExchange xmlns:xsd="http://www.w3.org/2001/XMLSchema"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns="http://schemas.abc.com/library/DataExchange">
<Data>
<ClaimData xmlns="">
<CurrentClaimNumber>TEST0000319001</CurrentClaimNumber>
</ClaimData>
</Data>
</DataExchange>
The query below is returning NULL values for the XML column because the ClaimData element uses an empty namespace, and I do not know how to indicate this in the query of the XML column.
Can someone give a working (and hopefully, tested) example of how to query the "CurrentClaimNumber" element (which is a child of "ClaimData") in the XML Message column?
Thanks very, very much.
WITH XMLNAMESPACES (
'http://www.w3.org/2001/XMLSchema' AS "xsd",
'http://www.w3.org/2001/XMLSchema-instance' AS "xsi",
DEFAULT 'http://schemas.rising.com/library/DataExchange'
) SELECT [StoredMessageID],
Message.value('(/DataExchange/Data/ClaimData/CurrentClaimNumber)[1]', 'CHAR(750)')
FROM [DataExchange].[dbo].[MessageStorage]