~工作簡化,不再是難事~

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'

0 意見:

張貼留言

Popular Posts

Copyright © 2016 Scenic's BOX. 技術提供:Blogger.