1
如何將XML保存到由SQL存儲過程生成的變量或表中?將XML結果保存到SQL中的變量或表中
這裏是我的示例:
DECLARE @ReportResultXml TABLE(RXml XML)
DECLARE @ResultXml XML = NULL
INSERT @ReportResultXml EXEC (@Script + ' FOR XML RAW, ROOT, XMLSCHEMA, ELEMENTS')
SELECT @ResultXml = RXml FROM @ReportResultXml
EXEC Repor.ProcInsert 1, @ResultXml
SELECT @ResultXml
的@Script
變量包含此SQL查詢:
DECLARE @PeriodID INT
SET @PeriodID = 12
SELECT TOP 10 PeriodID, Name
FROM Agent.Points
WHERE PeriodID = @PeriodID
該聲明將產生以下錯誤:
The FOR XML clause is not allowed in a INSERT statement.