使用存储过程的多个结果的Crystal Reports [英] Crystal Reports using multiple results from a Stored Procedure

查看:85
本文介绍了使用存储过程的多个结果的Crystal Reports的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我在sql-server中存储了proc,它返回的参数之一是带有查询参数的字符串。我将这些查询参数显示在报告的顶部。如果发现了某些东西,那很好用,如果什么也没发现,那不是很好。

I have a stored proc in sql-server and one of the parameters it returns is a string with the query parameters. I display those query parameters at the top of the report. That works great if something is found, not so great if nothing was found.

我们尝试返回两个查询结果,一个是我将用来生成报告的数据集(包括查询参数),另一个是查询参数字符串。 Crystal似乎只看到第一个数据集,而这是一个非常古老的讨论( http:/ /www.sqlteam.com/forums/topic.asp?TOPIC_ID=42462 )说,这行不通。但是那是5年前了,我希望一切都变了。

We have tried returning two query results, one the data set that I will make the report from (which includes the query parameters), the other the query parameter string. Crystal appears to only see the first data set, and this very old discussion (http://www.sqlteam.com/forums/topic.asp?TOPIC_ID=42462) says that is not something that will work. But that was over 5 years ago, and I'm hoping things have changed.

问题是,如果什么都没有返回,报告太空白了,那个人不会甚至不知道他们使用了哪些查询参数。如果他们看到他们查询的东西没有返回任何结果,那将是有用的。

The problem, is if nothing is returned, the report is so blank that the person doesn't even know what query parameters they used. If they could see that they queried something that doesn't return any results, that would be useful.

因此,如果我在存储过程的末尾有一个: / p>

So, if I have at the end of my stored proc:

SELECT * FROM [#ResultSet]
select @SearchCriteria as SearchCriteria

即使#ResultSet中没有任何内容,我也希望能够显示SearchCriteria。可以使用此版本的Crystal吗?还有另一种方法吗?

I'd like to be able to display the SearchCriteria even if there is nothing in the #ResultSet. Can it be done with this version of Crystal? Is there another way to do this?

推荐答案

除非第一个回答指出,一个过程的结果具有相同数量的另一个过程的列(包括类型),如果是这种情况,则可以对结果进行UNION或对所有结果进行UNION(如果要重复)以获得一个结果集。

Unless as stated by the first answer the results of one procedure have the same number of columns of another procedure (this includes type), if this is the case you can UNION the results or UNION ALL the results (if you want duplicates) to get ONE resultant set.

如果类型或列不同,则无法执行此操作。您唯一可以做的另一种选择是将所有相关数据合并到一个临时表中,然后从该临时表中返回结果( SELECT * FROM #temp

If the types or columns are not the same then you cannot do this. The only other option you can do is to merge all the relevant data into a temp table and then return the results from that temp table (SELECT * FROM #temp)

这篇关于使用存储过程的多个结果的Crystal Reports的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆