Click here to Skip to main content
15,867,453 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
I've heard that you can use linked servers, however is there another approach using C#? For example, I have a table of 3000+ machines in table A with each having a serial number, location, name, and several more identifiers. However, on table B, I have a smaller version of the same table with fewer machines but each machine still has the same serial number and name. If I wanted to add the location from table A and match them with the serial number of the machine in table B, how would I do so? (Without the use of linked servers).

What I have tried:

Basic C# commands, however I'm still confused as to how I would go about joining the two tables.
Posted
Updated 12-Nov-20 6:49am
Comments
PIEBALDconsult 12-Nov-20 10:49am    
Never used linked servers, they kill the performance of the whole system.

1 solution

Yes, you can use Linked Servers. I've personally never had performance issues when using them (see comment from @PIEBALDconsult) but it is something to consider - have a look into OPENQUERY instead e.g. see Best Performer: Distributed query (Four-part) or OPENQUERY when executing linked server queries in SQL Server | Microsoft Docs[^]

However, to answer your question about doing it in C# have a look at using LINQ to SQL - here are some starter resources
LINQ to SQL - ADO.NET | Microsoft Docs[^]
What You Can Do With LINQ to SQL - ADO.NET | Microsoft Docs[^]
And a specific article here on CP re using multiple databases LinqToSQL: Query Multiple Databases in One LINQ Expression and More...[^]
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900