I have the following Code,
@MasterXML= '
<Report MustUnderstand="df" xmlns="http://schemas.microsoft.com/sqlserver/reporting/2016/01/reportdefinition" xmlns:rd="http://schemas.microsoft.com/SQLServer/reporting/reportdesigner" xmlns:df="http://schemas.microsoft.com/sqlserver/reporting/2016/01/reportdefinition/defaultfontfamily">
<DataSets>
<DataSet Name="'+@Datasetname+'">
<Query>
</Query>
<Fields>
<Field>
</Field>
</Fields>
</DataSet>
</DataSets>
</Report> '
WHILE @i <= @Cnt
BEGIN
Select @xml=
(
SELECT @cname AS [@Name]
,@cname AS [DataField]
,'System.String' AS [rd:TypeName]
FOR XML PATH('Field')
);
SET @i = @i + 1
SET @MasterXML.modify(' insert sql:variable("@xml") as last into (Fields)[1] ' )
end
select @MasterXML
I am Generating a XMLat @xml through loop and i want to insert it after
I tried SET @MasterXML.modify(' insert sql:variable("@xml") as last into (Fields)[1] ' ), but the generated fields does not add up.
Can Anyone help me out?
@cnameis coming from, but this can be done without any loop or.modify()- at least I think so... My suggestion: There are some answers upon this question. If they solve it, please accept the one you like most and use your right to vote. Then set up a new question with some more information what you really try to achieve. This sounds like an xy-problem