I am having great difficulty trying to do a update without using a cursor.
I want to update Table B reducing its qty(s) by the qty in Table A. I am also not allowed to modify the qty in Table A.
I don't see a way of doing it because it needs to effect multiple rows.
It's quite easy to do using a cursor, but im trying to come away from using cursors.
Is a temporary table the way to go?
Can anyone point me in the right direction.
Table A
Code Qty
---- ---
A 20
B 50
C 35
Table B Before update
Code Line Qty
---- ---- ----
A 1 5
A 2 12
A 3 14
B 1 40
B 2 30
C 1 50
What table B should look like after update
Code Line Qty
---- ---- ----
A 1 0
A 2 0
A 3 11
B 1 0
B 2 20
C 1 15
I want to update Table B reducing its qty(s) by the qty in Table A. I am also not allowed to modify the qty in Table A.
I don't see a way of doing it because it needs to effect multiple rows.
It's quite easy to do using a cursor, but im trying to come away from using cursors.
Is a temporary table the way to go?
Can anyone point me in the right direction.
Table A
Code Qty
---- ---
A 20
B 50
C 35
Table B Before update
Code Line Qty
---- ---- ----
A 1 5
A 2 12
A 3 14
B 1 40
B 2 30
C 1 50
What table B should look like after update
Code Line Qty
---- ---- ----
A 1 0
A 2 0
A 3 11
B 1 0
B 2 20
C 1 15