Pages

2016-06-06

〔SQL〕UPDATE SELECT 利用SELECT做大量更新

範例:將訂單表身(OD00D1)出貨日,批次更新為訂單表頭(OD00H)出貨日


UPDATE
    OD00D1
SET
    OD00D1. DeliveryDate = OD00H. DeliveryDate,
    OD00D1. ProductDate = DATEADD( Day,-7 ,OD00H. DeliveryDate)
FROM
    OD00D1
    INNER JOIN OD00H
        ON OD00D1 .ODNo = OD00H .ODNo
WHERE

    OD00D1. ODNo = 'OD1606-00002'