Query across two different databases
I ran few times into this kind of situations, when I need to read two different databases and present it in single data table. It is always better to handle this in the db level. If not it is going to be a heavy looping at the server side.
So the following few samples are what I have used to fetch and combine data from different sources.
If you need data from two different databases, then
SELECT * FROM DB1.dbo.Table1
SELECT * FROM DB2.dbo.Table1
DB1.dbo.Table1 one inner join
DB2.dbo.Table1 Two on One.ColumnOne = Two.ColumnOne
If two databases are in different machines
then form the query like following