XML Query

  • Hi all,

    This is is quite simple, but i need you help pls!

    I need to get the value of one of the parameters (CustomProperty1) included in the Field of XML data type.

    Here the example of data in this field:

    DECLARE @XML XML

    SET @XML ='<CP>

    <CustomProperty1>Someroperty1</CustomProperty1>

    <CustomProperty2>Someroperty2</CustomProperty2>

    <CustomProperty3>Someroperty3</CustomProperty3>

    </CP>'

    Meaning, i want the select to return the value: Someroperty1

    Thanks!!

  • SELECT @XML.value('(/CP/CustomProperty1/text())[1]','VARCHAR(20)')

    ____________________________________________________

    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
  • Hi Mark-101232,

    Perfect!! Thanks for your help!!

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

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