I have two tables in two different SQL Server databases on different servers. Each table has the identical number of rows (each ~65000) and they are related by a common ID column. I created an object that has properties read and updated from these two tables.
I read all items from first table and create an instance of my object and then update properties of it. Then I add it into a List. After this is done I read from second table in order to update remaining properties of the object.
What can be the best way to do this? Do you have suggestions? At this moment I loop through my List and for each object in the list get data from the second server. Of course this is consuming time (~15 minutes).
For example is it possible to create a temporary table on one of the servers? The time I consume is in my loop. Time spent while retrieving data from these two servers are OK for me.
A solution would be to create a linked server:
http://msdn.microsoft.com/en-us/library/ms188279.aspx
Using this method, you can reference a database from a different server as if it were on the same server. This should allow you to do a join to complete your dataset.