Page 1 of 1

Combine data from two datasources

Posted: Fri Apr 24, 2020 10:44 am
by cbrydon
Hello,

I have a report with two different SQL Data Connections. Each Data Connection has one datasource. Both datasources
contain the same type of information (Equipment Name and Runtime hours), but from different periods of time. I would
like to be able to combine the two datasources into a third datasource.

Is it possible to create a new DataTable in the report with columns for EquipmentName and RuntimeHours and then in
the report BeginRender event loop through the rows from each datasource and populate the DataTable?

Perhaps using something like the following pseudo code...

rows = this.Dictionary.DataSources["DataSource1].Rows[]
for each row in rows
DataTable.Add(row(this.Dictionary.DataSources["DataSource1"].Columns["EquipmentName"],this.Dictionary.DataSources["DataSource1"].Columns["RuntimeHours"]))
rows.next()

rows = this.Dictionary.DataSources["DataSource2].Rows[]
for each row in rows
DataTable.Add(row(this.Dictionary.DataSources["DataSource2"].Columns["EquipmentName"],this.Dictionary.DataSources["DataSource2"].Columns["RuntimeHours"]))
rows.next()

Thanks,
Carl

Re: Combine data from two datasources

Posted: Mon Apr 27, 2020 10:43 am
by Lech Kulikowski
Hello,

It is not possible. Please try to use the "union" in your sql query.

Thank you.

Re: Combine data from two datasources

Posted: Mon Apr 27, 2020 11:31 am
by cbrydon
Thanks Lech,

I didn't think it was possible, but wanted to double-check. In this case the two datasources are from two different SQL connections so using a UNION isn't possible.
I'll probably end up using a Linked Server. Performance can sometime be slow with linked servers, but I won't be retrieving that much data so am not too concerned.

Carl

Re: Combine data from two datasources

Posted: Fri May 01, 2020 11:57 am
by Lech Kulikowski
Hello

Ok.
Please let us know if you need any additional help.

Thank you.