Modify XML using a variable

  • DECLARE

    @MyXML XML

    DECLARE

    @strMyXML varchar(2000)

    SET

    @MyXML='<ActorIdentity />'

    SET

    @strMyXML = 'insert <new>content</new> into (/ActorIdentity)[1]'

    SET

    @MyXml.modify(@strMyXML)  -- Do not work

    SET @MyXml.modify('insert <new>content</new> into (/ActorIdentity)[1]') -- works

    Is there any way I can get my last SET statement working.

     


    Kindest Regards,

    Amit Lohia

  • DECLARE

    @MyXML XML

    DECLARE @strMyXML varchar(2000)

    DECLARE

    @strMyElement varchar(2000)

    SET

    @MyXML='<ActorIdentity />'

    SET

    @strMyXML= 'ActorIdentity'

    SET

    @strMyElement= '<AA>AA</AA>'

    SET

    @MyXml.modify('insert @strMyElement into(/*[local-name()=sql:variable("@strMyXML")])[1]')

    SELECT

    @MyXml

    any solution how can I get @strMyElement  working


    Kindest Regards,

    Amit Lohia

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

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