SSRS 2008 是否支持 SQL 查询中的 XML 数据类型?

发布于 2024-11-09 05:26:37 字数 705 浏览 0 评论 0 原文

我有一个使用 XML 数据类型的查询。 (您可以在此处查看查询。)

需要明确的是,这意味着我的查询其中有这样的内容:

declare @xmlDoc XML

当我尝试将查询粘贴为 BIDS (Visual Studio 2008) 中的 SQL Server Reporting Services 报告的数据集时,会弹出一个对话框,要求我定义参数:

定义查询参数

问题是我没有任何参数!我在查询中定义并使用@xmldoc(它在 SSMS 中运行没有问题)。

我在这里输入什么似乎并不重要。这始终是下一个对话框:

“确定”关闭数据集属性,并且我没有为我设置任何字段。 “取消”让我返回属性并重试。如果我输入没有 XML 数据类型的查询,那么它可以正常工作。

我被难住了...我只能断定SSRS不支持XML数据类型。

这是真的吗?有解决办法吗?

I have an query that uses the XML data type. (You can see the query here.)

Just to be clear that means that my query has something like this in it:

declare @xmlDoc XML

When I try to paste my query in as a Dataset for a SQL Server Reporting Services Report in BIDS (Visual Studio 2008) a dialog pops asking me to define my parameters:

Define Query Parameters

The problem is that I don't have any Parameters! I define and use @xmldoc in the query (it runs with no issues in SSMS).

It does not really seem to matter what I enter here. This is always the next dialog box:

Error Message

"OK" closes the Dataset properties and I get no fields setup for me. "Cancel" gets me back to the properties to try again. If I put in a query without the XML data type then it works fine.

I am stumped... I can only conclude that SSRS does not support the XML data type.

Is that true? Is there a work around?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

病毒体 2024-11-16 05:26:37

您应该删除变量@xmldoc并在INSERT查询中使用

CAST(@DocParam as XML)

如下所示:

; With c as(SELECT CAST(@DocParam as XML) DocParam)
SELECT  TBL.SParam.value('local-name(.)[1]', 'varchar(50)') as Name,
        TBL.SParam.value('(.)[1]', 'varchar(50)') as Value1,
        TBL2.SParam2.value('(.)[1]', 'varchar(50)') as Value2,
        TBL3.SParam3.value('(.)[1]', 'varchar(50)') as Value3,
        TBL4.SParam4.value('(.)[1]', 'varchar(50)') as Value4,
        TBL5.SParam5.value('(.)[1]', 'varchar(50)') as Value5
FROM  C 
CROSS APPLY
 DocParam.nodes('/NewDataSet/Table1[1]/*') AS TBL(SParam)
        left JOIN DocParam.nodes('/NewDataSet/Table1[2]/*') AS TBL2(SParam2) 
            ON TBL.SParam.value('local-name(.)[1]', 'varchar(50)') 
               = TBL2.SParam2.value('local-name(.)[1]', 'varchar(50)')
        left JOIN DocParam.nodes('/NewDataSet/Table1[3]/*') AS TBL3(SParam3) 
            ON TBL.SParam.value('local-name(.)[1]', 'varchar(50)') 
               = TBL2.SParam2.value('local-name(.)[1]', 'varchar(50)')
        left JOIN DocParam.nodes('/NewDataSet/Table1[4]/*') AS TBL4(SParam4) 
            ON TBL.SParam.value('local-name(.)[1]', 'varchar(50)') 
               = TBL2.SParam2.value('local-name(.)[1]', 'varchar(50)')
        left JOIN DocParam.nodes('/NewDataSet/Table1[5]/*') AS TBL5(SParam5) 
            ON TBL.SParam.value('local-name(.)[1]', 'varchar(50)') 
               = TBL2.SParam2.value('local-name(.)[1]', 'varchar(50)')

第二个选项是有2个数据集,第一个设置@xmldoc参数值,第二个在查询中使用参数

第三个选项选项是使用包含所有逻辑的存储过程

You should remove variable @xmldoc and use

CAST(@DocParam as XML)

in INSERT query like this:

; With c as(SELECT CAST(@DocParam as XML) DocParam)
SELECT  TBL.SParam.value('local-name(.)[1]', 'varchar(50)') as Name,
        TBL.SParam.value('(.)[1]', 'varchar(50)') as Value1,
        TBL2.SParam2.value('(.)[1]', 'varchar(50)') as Value2,
        TBL3.SParam3.value('(.)[1]', 'varchar(50)') as Value3,
        TBL4.SParam4.value('(.)[1]', 'varchar(50)') as Value4,
        TBL5.SParam5.value('(.)[1]', 'varchar(50)') as Value5
FROM  C 
CROSS APPLY
 DocParam.nodes('/NewDataSet/Table1[1]/*') AS TBL(SParam)
        left JOIN DocParam.nodes('/NewDataSet/Table1[2]/*') AS TBL2(SParam2) 
            ON TBL.SParam.value('local-name(.)[1]', 'varchar(50)') 
               = TBL2.SParam2.value('local-name(.)[1]', 'varchar(50)')
        left JOIN DocParam.nodes('/NewDataSet/Table1[3]/*') AS TBL3(SParam3) 
            ON TBL.SParam.value('local-name(.)[1]', 'varchar(50)') 
               = TBL2.SParam2.value('local-name(.)[1]', 'varchar(50)')
        left JOIN DocParam.nodes('/NewDataSet/Table1[4]/*') AS TBL4(SParam4) 
            ON TBL.SParam.value('local-name(.)[1]', 'varchar(50)') 
               = TBL2.SParam2.value('local-name(.)[1]', 'varchar(50)')
        left JOIN DocParam.nodes('/NewDataSet/Table1[5]/*') AS TBL5(SParam5) 
            ON TBL.SParam.value('local-name(.)[1]', 'varchar(50)') 
               = TBL2.SParam2.value('local-name(.)[1]', 'varchar(50)')

Second option is to have 2 DataSets, first sets @xmldoc parameter value and second use parameter in query

An third option is to use stored procedure with all that logic inside

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文