SQLTeam.com | Weblogs | Forums

Grouping Data from two different Databases

Hi everyone,

I have two different external databases, I have extracted from each of them.
I have attached my two datases, they have few fields in common . i want to merge the data as shown in the final output. Is it possible to do that.

Please help me out

Picture1

Hi

hope this help ,

Even am not expert i tried my best :slight_smile:

Select t1.date,t1.RouteNO,t1.DriverNo,t2.Amt ,t2.Passid as [Pass ID],Dutyno as [Duty No] from Database2..Tab2 t2
left join Database1..Tab1 t1 on t1.Driverno = t2.DriverNo

Note : i have considered DriverNo to join two DataSets.

Answer is, it depends. If they are SQL databases on the same server and instance, then Vajeed's query will work, although it could be painful since it's crossing databases, so no indexes can be used. If they are 2 separate access databases or one is Oracle or even separate instances, then that would be worse. Can you explain more about the environments and what you are trying accomplish? Is this for reporting, one-time thing or something else?