In the ELMAH_Error table, the nText field is used to store the error record. I found that adding an XML type field; then adding this new field to the INSERT SPROC statement that populates the field; I could better use the ELMAH output.
Now I would like to learn how to request specific values of elements in this XML field. The document is structured as:
<error [...]>
<serverVariables>
<item name="ALL_HTTP">
<value string="..." />
</item>
<item name="ALL_RAW">
<value string="..." />
</item>
.
.
.
</serverVariables>
</error>
I need to be able to query the value of certain elements below.
So, I look at an example from article 15seconds.com :
SELECT MyXml.value('(/root/product[@id="304"]/name)[1]', 'nvarchar(30)')
and trying to match these values with my field structure, but I can’t. For instance.
select top 10 RealXML.value('(/error/serverVariables[@id="REMOTE_HOST"]/name)[0]', 'nvarchar(30)')
where REMOTE_HOST is formatted:
<item name="REMOTE_HOST">
<value string="55.55.55.55" />
</item>
much appreciated
source
share