繁体   English   中英

SSRS 2008不会从存储过程返回正确的数据集

[英]SSRS 2008 Wont return the correct Dataset from Stored Procedure

我有一个具有多个Query的过程,它根据使用的参数运行。

If Reportname = 'Foo'
Begin
Select Forename, Surname, Jobtitle, Gender from Staff where X = y
End

If ReportName = 'Bar'
Begin
Select EnrolmentID, StudentID, EnrolmentStartDate, EnrollmentExpectedEndDate, Status  from Enrolment where y = Z
End

如果我在SSMS中运行它,它将返回正确的记录和列。 在SSRS中,当我选择过程并设置参数时,它将可用列定义为过程的第一个Select语句中包含的列。

这个过程将用于各种不同的报告和后端处理,理想情况下我不想加倍代码。

有没有人得到任何关于如何让SSRS检测正在应用的正确上下文的建议?

我知道我可以将一些核心逻辑改为表值函数,它返回一些适用于所有情况的通用数据。

谢谢

还有没有人有说服我的老板从ADO Classic升级到ADO.Net实体框架的提示? 我特别喜欢EF的灵活性,因为我们在存储过程中做了所有事情,包括返回单个值,这让我很生气。

我会创建2个SP,每个SP返回2个案例的数据,然后您的“facade”SP设置为报告的来源可能如下所示:

CREATE TABLE #ReportTable(col1 ID, col2 varchar(80), etc)
IF Reportname = 'Foo'
Begin
    INSERT #ReportTable(col1, col2, ...)
    EXEC dbo.GetDataForReport1 '7131', 25
End

IF ReportName = 'Bar'
Begin
    INSERT #ReportTable (col1, col2, ...)
    EXEC dbo.GetDataForReport2 '7131', 25
End

SELECT col1, col2, ...
FROM #ReportTable

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM