xml node parse getting error while using openxml method RRS feed

  • Question

  • i'm working on importing xml data into sql using openxml method is working fine .but the data below is getting error while parse because of the single Quote or some other special character is available in <Cust_Name> that's the problem. how to solve this issue


    <Cust_Name>John P O'Connell</Cust_Name> -- not working

    <Cust_Name>John P OConnell</Cust_Name> -- working
    Sudhesh. G
    Thursday, March 10, 2011 12:41 PM


  • If it is a string in your query, something like

    declare @xmltext varchar(200);

    set @xmltext = '<Cust_Name>John P O'Connell</Cust_Name>'

    The error is that you have to escape the quote in the string:

    set @xmltext = '<Cust_Name>John P O''Connell</Cust_Name>'

    Russel Loski, MCT

    • Proposed as answer by Stefan Hoffmann Saturday, March 12, 2011 5:10 PM
    • Marked as answer by Ai-hua Qiu Sunday, March 20, 2011 9:23 AM
    Thursday, March 10, 2011 3:05 PM