XML Data- Data.exist ????

  • Hi

    I'm trying to parse out some XML date which looks like this N/A = Skip to "Other Information"(Double quotes are part of text)

     

    Using

    CASE

    WHEN x.Data.exist('Data/x0020_Focus/Service_x005F_x0020_Note_Option

    [Name="N/A = Skip to "Other Information""][Checked="true"]') = 1

    THEN 'Yes'

    END AS [N/A],

    Getting a syntax error

    I'm thinking its the way I have quotes but tried a few ways...

     

    Is there also a way I can use a LIKE?

    Thanks

    Joe

     

     

     

     

  • Don't you have to specify the quotes as "?

    It could help if you could include a sample XML document

    [font="Times New Roman"]Erland Sommarskog, SQL Server MVP, www.sommarskog.se[/font]

  • This is the XML data

    </Location>

    <Treatment_x0020_Focus>

    <PACT_x005F_x0020_Service_x005F_x0020_Note_Treatment_x0020_Focus_Option>

    <Name>N/A = Skip to "Other Information"</Name>

    <Checked>true</Checked>

    </PACT_x005F_x0020_Service_x005F_x0020_Note_Treatment_x0020_Focus_Option>

  • That's not a valid XML document. Not even a valid fragment. Please post something that can stored in a variable of the xml data type.

    [font="Times New Roman"]Erland Sommarskog, SQL Server MVP, www.sommarskog.se[/font]

  • Got it...

    needed Double quotes encasing the double quotes in the text ...

     

    Thanks for your time...

     

     

    CASE

    WHEN x.Data.exist('Data/Treatment_x0020_Focus/PACT_x005F_x0020_Service_x005F_x0020_Note_Treatment_x0020_Focus_Option

    [Name="N/A = Skip to ""Other Information"""][Checked="true"]') = 1

    THEN 'Yes'

    END AS [NA],

Viewing 5 posts - 1 through 4 (of 4 total)

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