sql - Stored Procedure Update no Common Field Table -
i have 2 tables, table a
has order no
, order line
, receiving no
, receiving date
, receiving qty
.
order order line receiving no receiving date receiving qty 1 455555 12/01/2013 10 1 455556 12/01/2013 15 1 455557 15/01/2013 7 1 455558 16/01/2013 10 1 455559 16/01/2013 10 1 455560 16/01/2013 15 1 455561 31/01/2013 7
table b
has order no
, order line
, invoice no
, invoice qty
, invoice date
.
order order line invoice no invoice date invoice qty 1 333331 13/01/2013 32 1 333332 15/01/2013 10 1 333333 01/02/2013 32
how create stored procedure update invoice no
, invoice qty
, invoice date
table b
table a
?
i'm new stored procedure, appreciated.
desired output :
order order line receiving no receiving date receiving qty invoice no invoice date invoice qty 1 455555 12/01/2013 10 333331 13/01/2013 10 1 455556 12/01/2013 15 333331 13/01/2013 15 1 455557 15/01/2013 7 333331 13/01/2013 7 1 455558 16/01/2013 10 333332 15/01/2013 10 1 455559 16/01/2013 10 333333 01/02/2013 10 1 455560 16/01/2013 15 333333 01/02/2013 15 1 455561 31/01/2013 7 333333 01/02/2013 7
write query in stored procedure
update tablea set ta.recievingno = tb.invoiceno, ta.recievingdate = tb.invoicedate ta.recievingqty = tb.invoiceqty tablea ta inner join tableb tb on ta.order = tb.order , ta.orderline=tb.orderline
Comments
Post a Comment