Home Forums SQL Server 2008 T-SQL (SS2K8) XQuery: Get the value only, and not the child node values RE: XQuery: Get the value only, and not the child node values

  • Use CROSS APPLY

    DECLARE @xml XML =

    '<ROOT>

    <SPECIALNEEDS>

    INCLUDE

    <NEED>

    BLIND

    </NEED>

    <NEED>

    BRAILLE AUDIO

    </NEED>

    </SPECIALNEEDS>

    </ROOT>'

    SELECT @xml AS xmlCol

    INTO #temptable

    SELECT TD.D.value('./text()[1]','Varchar(400)')

    FROM #temptable

    CROSS APPLY xmlCol.nodes('/ROOT/SPECIALNEEDS') AS TD(D)

    ____________________________________________________

    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