1
UPDATE PHYS_COUNT_TAG
SET COUNT_QTY = (
        SELECT qty
        FROM MC_PART_LOCATION
        WHERE MC_PART_LOCATION.part_id = PHYS_COUNT_TAG.PART_ID
            AND MC_PART_LOCATION.location_id = PHYS_COUNT_TAG.LOCATION_ID
    )

上面的代码不起作用。执行时出现错误:

Msg 4104, Level 16, State 1, Line 4
The multi-part identifier "PCT.PART_ID" could not be bound.
Msg 4104, Level 16, State 1, Line 5
The multi-part identifier "PCT.LOCATION_ID" could not be bound.
4

1 回答 1

3

试试这个 ( T-SQL) -

UPDATE p
SET COUNT_QTY = l.qty
FROM PHYS_COUNT_TAG p
JOIN MC_PART_LOCATION l ON l.part_id = p.PART_ID
    AND l.location_id = p.LOCATION_ID 
于 2013-06-10T05:36:40.470 回答