Append Xml Node Without Create new IDs. with Same Root.

  • SET @PreviousAddress = @xmlfile // Xml File With Tag i.e

    UPDATE TableName SET ColummnName.modify('

    insert

    (

    sql:variable("@PreviousAddress")

    )

    after

    (/NewDataSet[1])

    ')

    WHERE Condition here

    SELECT '0'

  • I think you may need to provide a little more information on what you are trying to do, sample code and what issues/errors that you are seeing. Showing an example xml structure of what you are trying to get to or what is going wrong etc.

    I've had a look at the query itself and it "looks" ok from a syntax point of view.

    Are you trying to insert an xml node into an existing xml node like the following rather than appending it at the bottom of the xml structure?

    DECLARE @xml XML

    SET @xml = '<NewDataSet></NewDataSet>'

    DECLARE @PreviousAddress XML

    SET @PreviousAddress = '<PreviousAddress>asdfadsF</PreviousAddress>'

    SET @xml.modify('insert (sql:variable("@PreviousAddress")) as first into (/NewDataSet)[1]')

    SELECT @xml

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

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