Let’s say that I have Table_A contain:
ID OldValue
3 16
1 5
and Table_B contains
ID Value OldValue
1 2 NULL
2 4 NULL
3 8 NULL
and that I want to insert OldValues from Table_A into Table_B where the IDs equal resulting in :
updated Table_B
ID Value OldValue
1 2 5
2 4 NULL
3 8 16
Is there a set based way of doing this without using a cursor? In real life this will be going on very large tables and cursors, as we all know are slow. Perhaps some sort of Merge?
I’m on SQL Server 2008
1 Answer