[英]Is it possible to use XML dataset in SSRS report designer
是否可以在SSRS报表设计器中使用XML数据集? 我需要获取一个大型数据集,例如
Master Row
- Details1
- Details2
- ... DetailsN
我已经创建了查询,该查询使用FOR XML RAW
返回了XML数据,但是添加新报表时,我无法在查询设计器中使用它。
请注意,我没有使用XML数据源,我只是想使用SELECT查询来添加XML数据集。我没有尝试过存储过程,但是不确定它是否也可以正常工作...
换句话说,是否可以将XML数据集(非数据源)添加到SSRS报告中
如果需要看起来像树视图的XML,则可以执行以下操作:
DECLARE @xml XML=
'<root>
<level content="Level A">
<detail content="Detail AA">
<item content="item AAA" />
</detail>
<detail content="Detail AB">
<item content="item ABA" />
<item content="item ABB" />
<item content="item ABC" />
</detail>
<detail content="Detail AC">
<item content="item ACA" />
<item content="item ACB" />
</detail>
</level>
<level content="Level B">
<detail content="Detail BA">
<item content="item BAA" />
</detail>
<detail content="Detail BB">
<item content="item BBA" />
<item content="item BBB" />
<item content="item BBC" />
</detail>
<detail content="Detail BC">
<item content="item BCA" />
<item content="item BCB" />
</detail>
</level>
</root>';
SELECT CASE The.Node.value('fn:local-name(.)','varchar(max)')
WHEN 'level' THEN ''
WHEN 'detail' THEN REPLICATE(' ',4)
WHEN 'item' THEN REPLICATE(' ',8)
ELSE ''
END + The.Node.value('@content','varchar(max)')
FROM @xml.nodes('root//*') AS The(Node)
结果
Level A
Detail AA
item AAA
Detail AB
item ABA
item ABB
item ABC
Detail AC
item ACA
item ACB
Level B
Detail BA
item BAA
Detail BB
item BBA
item BBB
item BBC
Detail BC
item BCA
item BCB
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.