Query Xml message

  • Hello,

    I have a column called "message" in side each message is a HUGE xml response. I need to pick out the line that has "error" in it not the whole xml response.

    so far I have:

    Select *

    From tablename

    Where message like ‘error%’

    any help would be awesome

    Thanks

  • If 'Message' column has XML data type than you can construct XPath query to retrieve the error message.

    Check following article on MSDN where you can find all kinds of queries that could be helpful to construct XPath expression.

    http://msdn.microsoft.com/en-us/library/ms345117(v=sql.90).aspx

    Try using value() function.

    The value() method extracts a scalar value from an XML instance. It returns the value of the node the XQuery expression evaluates to. This value is converted to a Transact-SQL type specified as the second argument of the value() method.

    If this won't help, try posting sample Message so the XPath expression can be established.

    Cheers, Max

    Check-out free open-source utility Sql Server Replication Explorer[/url]

Viewing 2 posts - 1 through 1 (of 1 total)

You must be logged in to reply to this topic. Login to reply