简体   繁体   English

如何将非表数据导入SQL Server Reporting Services?

[英]How do I get non-Table data into SQL Server Reporting Services?

Given: AC# calculation engine that loads an object model, crunches huge amounts of numbers, and saves the results to a couple of gigantic mega-indexed database tables in SQL Server. 给定:AC#计算引擎加载对象模型,压缩大量数字,并将结果保存到SQL Server中的几个巨大的索引数据库表中。 Those tables provide data to web interfaces, other software modules, and SQL Server Reporting Services 2005 reports. 这些表为Web界面,其他软件模块和SQL Server Reporting Services 2005报告提供数据。

I managed to make the engine a lot faster in the latest version of the software, fast enough now that it can provide the data on request - sometimes even faster than the time it takes to query the database for the pre-calculated numbers. 我设法使发动机在软件的最新版本快了很多 ,速度不够快,现在,它可以要求提供数据-有时甚至比它需要在数据库中查询预先计算的数字的时间更快。 I am very happy about this. 我对此感到非常高兴。

That breakthrough means that we can generate data on request for the web interfaces and other software modules. 这一突破意味着我们可以根据Web界面和其他软件模块的请求生成数据。 But the cache tables cannot die yet, because they're consumed by the SSRS reports (or more specifically, by stored procedures that query the tables and provide the data to SSRS.) 但是缓存表还不会死,因为它们被SSRS报告(或者更具体地说,通过查询表并将数据提供给SSRS的存储过程)使用。

The cache tables are a pain, in much the same way that any cache is a pain in the world of software. 缓存表很痛苦,就像任何缓存都是软件世界的痛苦一样。 Without going into too much detail, they have sync'ing problems, locking problems, etc etc. The software would work so much more nicely if I didn't have to worry about keeping those darned tables up to date. 没有太多的细节,他们有同步问题,锁定问题等等。如果我不必担心保持这些darned表更新,软件将更好地工作。

But how else can I get the data into SSRS? 但我怎样才能将数据导入SSRS? I've done a fair bit of research and nothing looks too promising: 我做了很多研究,没有什么看起来太有希望了:

  • We could provide the data via a web service and use the SSRS XML DPE. 我们可以通过Web服务提供数据并使用SSRS XML DPE。 But that looks kind of hideous - am I right that you have to parse your SOAP envelope yourself?! 但这看起来有点可怕 - 我是对的,你必须自己解析你的SOAP信封吗?! And it doesn't support XPath, but a proprietary XPath-y dialect?? 它不支持XPath,而是一种专有的XPath-y方言? Our report writers know T-SQL, and that's what they're best at. 我们的报告编写者了解T-SQL,这就是他们最擅长的。
  • Using the SQL CLR to host our API is not desirable - it's a big app and you can't do anything without creating an application object and logging in, etc. 使用SQL CLR来托管我们的API是不可取的 - 它是一个很大的应用程序,如果不创建应用程序对象并登录等,你就无法做任何事情。
  • Using the SQL CLR to contact a web service on the web application - this is the most promising so far (this article was helpful http://www.simple-talk.com/sql/sql-server-2005/practical-sql-server-2005-clr-assemblies/ .) Has anybody tried this approach? 使用SQL CLR联系Web应用程序上的Web服务 - 这是迄今为止最有希望的(本文有用http://www.simple-talk.com/sql/sql-server-2005/practical-sql- server-2005-clr-assemblies / 。)有没有人尝试过这种方法? Does it perform okay, can it provide large data sets? 它是否运行良好,是否可以提供大型数据集? OTOH I'm turned off by the extra setup we would have to do on client DB servers. OTOH我被客户端数据库服务器上的额外设置关闭了。
  • Any other suggestions would be greatly appreciated. 任何其他建议将不胜感激。

If I understand you correctly, you're building a report on non-SQL data. 如果我理解正确,那么您正在构建有关非SQL数据的报告。 You're storing the data in tables for the specific purpose of making them reportable. 您将数据存储在表中,以实现使其可报告的特定目的。

I can think of two solutions. 我能想到两个解决方案。 The first is to extend your C# calculation engine with a reporting part . 第一种是使用报告部分扩展您的C#计算引擎。 The Microsoft.Reporting.WinForms and Microsoft.Reporting.WebForms namespaces can be used to build reports on any data source, not just SQL Server. Microsoft.Reporting.WinForms和Microsoft.Reporting.WebForms命名空间可用于在任何数据源上构建报告,而不仅仅是SQL Server。 If the end users use your app as a client, you can generate the data and the reports on the fly. 如果最终用户将您的应用用作客户端,则可以即时生成数据和报告。

The second is to use the SQL CLR. 第二种是使用SQL CLR。 You can use a CLR stored procedure as the basis for a report (enter "exec mysp" as the datasource.) This CLR procedure is C# code, and could include your calculation engine as a library. 您可以使用CLR存储过程作为报告的基础(输入“exec mysp”作为数据源。)此CLR过程是C#代码,可以将您的计算引擎包含为库。 This would allow you to generate reports on the fly, while still using the Report Server user interface. 这样您就可以动态生成报告,同时仍然使用Report Server用户界面。

Interesting question and I'm hoping that more knowledgeable people can provide a better answer :) 有趣的问题,我希望更有知识的人能提供更好的答案:)

I've been in a similar situation previously and tried both the SSRS XML data source and the reporting extension that Andomar mentions. 我之前遇到过类似情况,并尝试过SSRS XML数据源和Andomar提到的报告扩展。 My recommendation is to use the SSRS XML data source feature. 我的建议是使用SSRS XML数据源功能。 If the data structure returned by the web service is simple then the XPath is also simple. 如果Web服务返回的数据结构很简单,那么XPath也很简单。 I also found it easier to debug. 我还发现它更容易调试。 Main thing to watch out for is the timeouts. 需要注意的主要是超时。

The good thing with using web services is that they are easily consumed by many different technologies so they can become very handy to have anyway. 使用Web服务的好处在于它们很容易被许多不同的技术所使用,因此无论如何它们都可以变得非常方便。

Also, it's a personal choice but despite the SQL CLR features I still don't feel comfortable with putting code in the database. 此外,这是个人选择,但尽管有SQL CLR功能,我仍然觉得将代码放入数据库感觉不舒服。 By using an XML data source in SSRS there is no need to involve custom CLR code at all. 通过在SSRS中使用XML数据源,根本不需要涉及自定义CLR代码。

You could wrap your data in an ADO.NET DataSet and use it as a Reporting Services Data Source. 您可以将数据包装在ADO.NET DataSet中,并将其用作Reporting Services数据源。 .

I've never personally used this, so I can't give you much more information. 我从来没有亲自使用过这个,所以我不能给你更多的信息。 However, I knew you could do this from a SSRS class I attended. 但是,我知道你可以从我参加的SSRS课程中做到这一点。 The example the instructor gave me for when you would do this in a "real world" example would be if you need to join data from two different data sources. 教师在“真实世界”示例中执行此操作时给出的示例是,如果您需要连接来自两个不同数据源的数据。 For example, you would do this if you wanted to correlate data from SQL Server and Oracle together in one report. 例如,如果要在一个报表中将SQL Server和Oracle中的数据关联在一起,则可以执行此操作。

I know this isn't what you want to do, but it sounds like it would provide the same layer of abstraction that you need. 我知道这不是你想要做的,但听起来它会提供你需要的同一层抽象。

Have you considered writing your own custom database driver that sits on top of your calculation engine? 您是否考虑过编写位于计算引擎之上的自定义数据库驱动程序? You could then point reporting services right at it. 然后,您可以将报告服务指向它。 This would keep things fast although it may be a complicated task. 尽管这可能是一项复杂的任务,但这会使事情变得更快。 I've considered it in the past for proprietary data warehouse software I was working on but never got the go ahead to build the driver. 我过去曾经考虑过我正在开发的专有数据仓库软件,但从来没有开始构建驱动程序。

Great question by the way. 顺便问一下很棒的问题。

Using the SQL CLR to contact a web service on the web application 使用SQL CLR联系Web应用程序上的Web服务

This is the way I'd recommend - I did this to access SharePoint list data via their web services. 这是我推荐的方式 - 我这样做是为了通过他们的Web服务访问SharePoint列表数据。 If the data schema can be fixed, a SQL CLR TVF might be a good fit and yields the greatest flexibility. 如果可以修复数据模式,那么SQL CLR TVF可能非常适合并且具有最大的灵活性。 If you need to the schema to be determined at execute time, a SQL CLR stored procedure is what you want since it is not bound to a schema. 如果需要在执行时确定模式,则SQL CLR存储过程就是您想要的,因为它未绑定到模式。

The key things you'll need is to: 您需要的关键是:

-- enable CLR on the server
sp_configure 'clr_enabled', 1
GO
RECONFIGURE
GO

-- allow your db to execute clr code marked EXTERNAL or UNSAFE
alter database mydb set trustworthy on

then create a VS sql clr project (you don't have to but it help with deploying and debugging it), set the permission level to 'external'. 然后创建一个VS sql clr项目(您没有必要,但它有助于部署和调试它),将权限级别设置为“外部”。 If you use "Add Web Reference" in the VS project, you'll have to turn on the generation of the serialization assembly and CREATE ASSEMBLY to load it after you build/deploy. 如果在VS项目中使用“添加Web引用”,则必须在生成/部署后打开序列化程序集和CREATE ASSEMBLY的生成以加载它。

This is a little hand-wavy right now -- honest, I've done this -- I'll add some more detail later. 现在这是一个小小的波浪形 - 老实说,我已经做到了 - 我稍后会添加一些细节。 I gave a talk on SQL CLR last month. 上个月我在SQL CLR上发表了演讲。 My sample code has GetFibs project that calls a web service (Fibonnaci) which is also included. 我的示例代码包含调用Web服务(Fibonnaci)的GetFibs项目,该服务也包含在内。

Also take a look here: http://footheory.com/blogs/bennie/archive/2006/12/07/invoking-a-web-service-from-a-sqlclr-stored-procedure.aspx and http://www.codeproject.com/KB/database/SQLCLR.aspx?display=Print 另请查看: http: //footheory.com/blogs/bennie/archive/2006/12/07/invoking-a-web-service-from-a-sqlclr-stored-procedure.aspxhttp:// www.codeproject.com/KB/database/SQLCLR.aspx?display=Print

Does it perform okay, can it provide large data sets? 它是否运行良好,是否可以提供大型数据集?

Yes, it seems to perform well. 是的,它似乎表现良好。 With a little extra work, you can build it in a more stream oriented manner where it won't consume memory for the whole set. 通过一些额外的工作,您可以以更加流的方式构建它,它不会占用整个集合的内存。 See how in the Range sample or here . 请参阅Range示例或此处的说明

I would deinitely go down the ADO.NET DPE road . 我绝对会走ADO.NET DPE之路 If your data source can provide the neccessary data in real time, then it would make most sense. 如果您的数据源可以实时提供必要的数据,那么它将是最有意义的。 You will save yourself 1,2 or 3 tiers, which would surely improve the overall performance. 您将节省1,2或3层,这肯定会提高整体性能。 And not talk about maintenance of each layes of code. 而不是谈论每个代码的维护。 Expose the number crunched data as an ADO.NET dataset and let your reporting services query it directly, is the best in my opinion. 将数字压缩数据公开为ADO.NET数据集,让您的报表服务直接查询,在我看来是最好的。

In SQL 2008 you can use a SQL SSIS package as a datasource. 在SQL 2008中,您可以使用SQL SSIS包作为数据源。 Write a SSIS package to execute your calculation engine on the fly and output an in-memory .net dataset (DataReaderDestination). 编写SSIS包以动态执行计算引擎并输出内存中.net数据集(DataReaderDestination)。 This can then be used for reporting. 然后可以将其用于报告。

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

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