I have a large database table with an XML column. The XML contents is a kind of document like as below:
<?int-dov version="1.0" encoding="UTF-8" standalone="no"?>
<ds:datastoreItem ds:itemID="{F8484AF4-73BF-45CA-A524-0D796F244F37}" xmlns:ds="http://schemas.openxmlformats.org/officeDocument/2006/customXml"><ds:schemaRefs><ds:schemaRef ds:uri="http://schemas.openxmlformats.org/officeDocument/2006/bibliography"/></ds:schemaRefs></ds:datastoreItem>
I'm seeking a function or fast way to fetch standalone attribute value in a T-SQL query. When I run the below query:
select XmlContent.query('@standalone') from XmlDocuments
I get this error message:
Msg 2390, Level 16, State 1, Line 4
XQuery [XmlDocuments.XmlContent.query()]: Top-level attribute nodes are not supported
So, I would be appreciated if anybody gives me a solution to address this problem.