SSRS:解析具有 XML 列的 SQL Server 查询的结果
我正在查看以下查询:
SELECT txt.ID, txt.Rev, txt.Words,
flds.ReferenceName
FROM Fields flds (NOLOCK)
JOIN WorkItemLongTexts txt (NOLOCK)
ON flds.FldID = txt.FldID
WHERE flds.ReferenceName = 'Microsoft.VSTS.TCM.Steps'
第三列 (txt.Words) 返回此值:
<steps id="0" last="3">
<step id="1" type="ValidateStep">
<parameterizedString>
<text>Step 1</text>
</parameterizedString>
<parameterizedString>
<text>Result 1</text>
</parameterizedString>
<description />
</step>
<step id="2" type="ValidateStep">
<parameterizedString>
<text>Step 2</text>
</parameterizedString>
<parameterizedString>
<text>Result 2</text>
</parameterizedString>
<description />
</step>
</steps>
显然,我可以使用 .net 客户端应用程序轻松解析此值。但是,我想将此查询直接放入 SSRS 报告中。
有没有办法将此列中的数据放入 SSRS 可使用的数据集中,如下所示:
1 |验证步骤 |步骤 1 |结果1
2 |验证步骤 |步骤 2 |结果 2
(或类似结果)
I am looking at the following query:
SELECT txt.ID, txt.Rev, txt.Words,
flds.ReferenceName
FROM Fields flds (NOLOCK)
JOIN WorkItemLongTexts txt (NOLOCK)
ON flds.FldID = txt.FldID
WHERE flds.ReferenceName = 'Microsoft.VSTS.TCM.Steps'
The third column (txt.Words) returns this value:
<steps id="0" last="3">
<step id="1" type="ValidateStep">
<parameterizedString>
<text>Step 1</text>
</parameterizedString>
<parameterizedString>
<text>Result 1</text>
</parameterizedString>
<description />
</step>
<step id="2" type="ValidateStep">
<parameterizedString>
<text>Step 2</text>
</parameterizedString>
<parameterizedString>
<text>Result 2</text>
</parameterizedString>
<description />
</step>
</steps>
Clearly I can easily parse this out with a .net client side application. However, I would like to take this query directly into a SSRS report.
Is there a way to get the data from this column into a SSRS consumable dataset like this:
1 | ValidateStep | Step 1 | Result 1
2 | ValidateStep | Step 2 | Result 2
(or anything similar)
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
您可以使用 TSQL 的 OpenXML 功能从 xml 数据获取行集,但是您想要元素和属性的组合,因此这将是一个小工作。
You can use TSQL's OpenXML functionality to get a rowset from your xml data, however you want a combination of elements and attributes so it will be a little work.
我对 ssrs 一无所知,但以下是我在常规查询中的做法。也许它是你可以使用的东西。
我已经简化了您的示例并使用表变量。我假设 XMLColumn 的数据类型为
xml
。结果
I don't know anything about
ssrs
but here is how I would do it in a regular query. Perhaps it is something you can use.I have simplified your sample and uses a table variable instead. I assume that the XMLColumn has datatype
xml
.Result