Resolved Need to insert differences between Staging and Working tables into the Working Table

tim8w

Well-known member
Joined
Sep 8, 2020
Messages
131
Programming Experience
10+
Hi,
Still kind of a newbie to SQL Server. Anyway I have two tables: tblStaging and tblWorking. The staging table is updated every 15 minutes and I need to look at what's different in the Staging table and insert the differences into the Working table. I have a combination of two fields that guarantee uniqueness. I also need to go the other way and look at what's in the Working table, that's not in the Staging table and delete those records from the Working table. Sorry for the wordiness. Just wanted to make things clear...
 
Sounds like a SQL problem, rather than a C# problem, specially if you want to solve it efficiently.

If you want to solve it the inefficient C# way, the approach would be to query all the items from both tables and use the LINQ to objects to use the LINQ Except() extension method to determine what items are in one table, but not the other.


You could also use LINQ to SQL which should be more efficient, but I am just guessing since I don't know if that will do the appropriate SQL server side operations, or if it will still do things inefficiently on the client side.
 
You guys were correct. I should have gone to a strict SQL Server forums, which I have done. Thanks!
 
Back
Top Bottom