0

我有 2 张桌子,Table AOrder No, Order Line, receiving no, receiving date, receiving qty

Order Order Line Receiving No  Receiving Date  Receiving Qty
A      1         455555        12/01/2013       10
A      1         455556        12/01/2013       15
A      1         455557        15/01/2013       7
A      1         455558        16/01/2013       10
A      1         455559        16/01/2013       10
A      1         455560        16/01/2013       15
A      1         455561        31/01/2013       7

Table BOrder No, Order Line, Invoice no, Invoice Qty, Invoice Date.

Order Order Line Invoice no  Invoice Date   Invoice Qty  
A     1          333331      13/01/2013      32
A     1          333332      15/01/2013      10
A     1          333333      01/02/2013      32

如何创建存储过程来更新Invoice No,Invoice QtyInvoice Datefrom ?Table BTable A

我对存储过程很陌生,任何帮助将不胜感激。

期望的输出:

Order Order Line Receiving No  Receiving Date  Receiving Qty  Invoice No  Invoice Date    Invoice Qty
 A      1         455555        12/01/2013       10            333331         13/01/2013     10
 A      1         455556        12/01/2013       15            333331         13/01/2013     15
 A      1         455557        15/01/2013       7             333331         13/01/2013     7
 A      1         455558        16/01/2013       10            333332         15/01/2013     10
 A      1         455559        16/01/2013       10            333333         01/02/2013     10
 A      1         455560        16/01/2013       15            333333         01/02/2013     15
 A      1         455561        31/01/2013       7             333333         01/02/2013     7
4

1 回答 1

0

在您的存储过程中编写此查询

UPDATE TableA
SET ta.RecievingNo = tb.InvoiceNo,
    ta.RecievingDate = tb.InvoiceDate
    ta.RecievingQty = tb.InvoiceQty
FROM TableA ta
INNER JOIN TableB tb
   ON ta.Order = tb.Order AND ta.OrderLine=tb.OrderLine
于 2013-05-09T02:56:37.737 回答