Friday, 31 January 2014

In SSRS populate table querying from two different servers without using Linked servers

Have you ever happened to query from  two different servers to fill report table in SSRS? Here is a trick that do not need to use Linked Server but using two data sources.
First you need to create two separate data sources for each different server.
Then create two datasets (write the query) and link each for the created datasources.
The trick is to use the LOOKUP function.
 
=LookUp(Fields!emp_no.Value,Fields!emp_no.Value,Fieldsleave_hrs.Value,"DataSet2")

If I check the tablix properties it has been set to "DataSet1". In the Expr I use is the above function passing Dataset1 value and then pass Dataset2 value. Third parameter is to bring values from Dataset 2. Last parameter is the name of the other dataset. LOOKUP function returns the
first matching row.  

 Lookup(source_expression, destination_expression, result_expression, dataset)

 

No comments:

Post a Comment