Query XML data stored in table text column

  • with cte as (

    select DocID,cast(Doc as xml) as Doc

    from mytable)

    select Page.value('@page_number','int') as Page_number,

    Redaction.value('Top[1]','int') as [Top],

    Redaction.value('Left[1]','int') as [Left],

    Redaction.value('Width[1]','int') as Width,

    Redaction.value('Height[1]','int') as Height,

    Redaction.value('Text[1]','varchar(100)') as [Text]

    from cte

    cross apply Doc.nodes('/pages/Page') as x(Page)

    outer apply Page.nodes('redactions/Redaction') as y(Redaction)

    ____________________________________________________

    Deja View - The strange feeling that somewhere, sometime you've optimised this query before

    How to get the best help on a forum

    http://www.sqlservercentral.com/articles/Best+Practices/61537

Viewing post 1 (of 2 total)

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