简体   繁体   English

SSRS报表生成器2.0如何链接2台服务器并在一个数据集中运行

[英]SSRS report builder 2.0 How to link 2 servers and run in one dataset

I am trying to find a way of linking data from two servers in SSRS report builder 2.0 我正在尝试找到一种方法来链接来自SSRS Report Builder 2.0中两个服务器的数据

ultimately using one dataset to query 2 databases in 2 different servers. 最终使用一个数据集查询2个不同服务器中的2个数据库。

The SQL that i have is very basic as shown below and i can run the query easily in SQL management studio. 我拥有的SQL非常基本,如下所示,我可以在SQL Management Studio中轻松运行查询。

select * from
[server1].[DES].[dbo].[Daily] dr 
LEFT JOIN [server2].[VES].[dbo].[Rou] mr
ON dr.ID = mr.id

Also the access i have to the reporting server is read only so i cant really make any administrative changes to the configuration. 我对报告服务器的访问权限也是只读的,因此我无法真正对配置进行任何管理更改。

I have explored the connection string to create a connection but it only allows me to connect to one server for each dataset. 我已经探索了连接字符串来创建连接,但是它只允许我为每个数据集连接到一台服务器。 what i am trying to do is use one dataset 我想做的是使用一个数据集

Any help will be greatly appreciated as i am a junior in SQL and SSRS 由于我是SQL和SSRS的大三学生,因此任何帮助将不胜感激。

Using SSRS and MS SQL 2008 R2 使用SSRS和MS SQL 2008 R2

if you executing this query from your SSMS it means this other server is a linked server. 如果您从SSMS执行此查询,则表示该另一台服务器是链接服务器。 then it should be no different to execute it from SSRS. 那么从SSRS执行它应该没有什么不同。

Yes it is right you can only add one server to your data source of your dataset whether its a shared data source or embedded. 是的,您只能将一台服务器添加到数据集的数据源,无论是共享数据源还是嵌入式服务器。

But for instance if you have a data source pointing to say Server A when you executing queries which will be pulling data from Server A and also from server B you will Use fully Qualified name for the Objects from server B and two part name from server A. 但是,例如,如果您在执行查询时指向服务器A的数据源将要从服务器A以及服务器B提取数据,则将对服务器B中的对象使用完全合格的名称,而对服务器A中使用两部分的名称。

something like this ... 像这样的东西...

SELECT * 
FROM Schema.Table_Name A INNER JOIN [ServerNameB].DataBase.Schema.TableName B
ON A.ColumnA = B.ColumnA

obviously ServerB has to be a Linked Server . 显然ServerB必须是一个Linked Server

I can think of two possible solutions 我可以想到两种可能的解决方案

Option 1: Creating a stored procedure on server1 (With a query accessing the another server). 选项1:在server1上创建存储过程(通过查询访问另一台服务器)。 And call this stored procedure from SSRS (Dataset). 并从SSRS(数据集)调用此存储过程。

Option 2: Create two dataset with two different connection strings on the RDL (one for Server1 and another for Server2). 选项2:在RDL上创建具有两个不同连接字符串的两个数据集(一个用于Server1,另一个用于Server2)。 Use the " LookUpDataSet " function in Report Builder to merge the results using the key fields. 在报表制作工具中使用“ LookUpDataSet ”功能可以使用关键字段合并结果。

Option 2 is preferable. 选项2是更可取的。

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

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