Home Forums Programming XML Setting the value of an XML attribute using a relational variable RE: Setting the value of an XML attribute using a relational variable

  • If i understand you correctly, you have an xml instance as a string which you want to assign directly to an xml variable whilst at the same time, populating some nodes in the xml string with other variables from the transaction scope? I'm probably not entirely understanding everything, but I have come up with this:

    DECLARE @FullPathAndName varchar(100)

    SET @FullPathAndName = 'C:\DBA_Share\SSRS\Output\MyReport.rpt'

    DECLARE @xVar XML = ''

    SELECT @xVar = @xVar.query('for $x in ("") return

    <package name="\File System\ReportToExcel" owner="sa" runAs="">

    <variable name="Cnfg_ReportPath" value="C:\DBA_Share\SSRS\"/>

    <variable name="vSourceQuery" value="select * from dbo.sometable"/>

    <variable name="vFileName" value="{sql:variable("@FullPathAndName")}"/>

    </package>')

    SELECT @xVar

    Does this help? if not, then if you can go into a bit more of the scenario that you have and what is your end goal.