I have a SQL Server database table that I need to update with values that I have in a C# application DataTable
retrieved from an outside source (it could be from file, external API call, etc I guess it is irrelevant).
Is there a way to do a "mass" update using SQL similar to:
UPDATE myTable1 t1
SET custAddress = t2.address
FROM myTable2 t2
WHERE t1.id = t2.id
I suppose I could use the above example as long as both tables are in the same SQL Server database; but in this case, myTable2
is an application (C#) DataTable
and not a SQL Server table.
Is there a way to accomplish the update similar to the one above?
I know I could "loop" through each of the application table rows and trigger a SQL update for each row, but if my data table has thousands of rows, I would not want (whenever possible) to have to execute one SQL update for each row that I need to update.
Any help would be appreciated. I am open to solutions or suggestion that involve LINQ or any other C# or SQL logic.