本文介绍了在SSRS中使用存储过程作为查询类型时,在text参数中返回多个字符串的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧! 问题描述 Hello 我有一份SSRS报告,出于各种原因,最好是作为存储过程运行。它基本上显示了工作人员在特定日期之间完成的工作。 它依赖于SSRS中两个数据集的两个查询: CREATE PROC EDURE @ date1 AS DATETIME = '19000101' , @ date2 AS DATETIME = '99991231' , @Officer AS NVARCHAR ( Max ) AS BEGIN SELECT DISTINCT * FROM TABLES WHERE (a 。officer IN ( @ Officer )) AND ( a 。 date1 > = @ date1 ) AND ( a .date2 < = @ date2 ); END ; 然后是一个更简单的查询,返回@Officer参数的值: 选择不同的b officer.name 来自官员 其中 officer.name IN('John.Smith','Joan.Smith'等等); 然而 - 当我运行报告时,我现在发现@Officer参数只有在选择了一个人员姓名时才有效 - 而不是多个名字。在'普通'SSRS我可以选择多个人员姓名。我已经设置了'允许多个值'设置的@Officer参数,另外我在'可用值'中选择了正确的数据集和正确的值和标签字段。所有的官员名称都出现在我身上运行报告 - 这只是我现在一次只能选择一个。 我很怀疑这是由使用存储过程引起的,但是如果我这样做会非常有帮助可以选择一个以上的官员t下拉参数中的时间。日期参数工作正常。 如果有某种表达 - 或者在其他地方调整 - 这将有助于此 - 请让我知道。基本上在存储过程之前,我可以选择多个名称 - 在我一次只能选择1之后。 解决方案 您不能在存储过程中使用Multi Value参数。您需要在存储过程中处理它们。 。请参阅第2部分如何使用以下博客中的列表 http://www.sommarskog.se/arrays-in-sql.html HelloI have an SSRS report that for various reasons would be preferable to run as a stored procedure. It basically shows jobs done by staff between particular dates.It relies on two queries for two datasets within SSRS:CREATEPROCEDURE@date1ASDATETIME='19000101',@date2 ASDATETIME='99991231',@Officer ASNVARCHAR(Max)ASBEGINSELECT DISTINCT *FROMTABLESWHERE(a.officerIN(@Officer))AND(a.date1>=@date1)AND(a.date2<=@date2);END;And then a simpler query that returns values for the @Officer parameter:Select distinctofficer.nameFROM officerWhereofficer.name IN ('John.Smith', 'Joan.Smith' etc etc);However - when I run the report I now find that in the @Officer parameter will only work if one officer name is selected - not multiple names. In 'normal' SSRS I can select multiple officer names. I have the @Officer parameter set up with 'allow multiple values' ticked and in addition I have selected, in 'available values' the correct dataset and the correct value and label field. All the officer names appear when I run the report - it's just that I can only select one at a time now.I've little doubt this has been caused by using a stored procedure but it would be very helpful if I could select more than one officer at a time in the drop down parameter. The date parameters work fine. If there's some sort of expression - or tweak somewhere else - that will help with this - please let me know. Essentially before the stored procedure I could select multiple names - after I can only select 1 at a time. 解决方案 You cannot use the Multi Value parameter as-is in the stored procedure. You need to process them in stored procedure. .Please refer the 2nd section how to work with list in the below bloghttp://www.sommarskog.se/arrays-in-sql.html 这篇关于在SSRS中使用存储过程作为查询类型时,在text参数中返回多个字符串的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持! 10-27 16:00