update single row error
UPDATE property p
SET (mfr_name_id ) = (
SELECT (mfr_name_id)
FROM eqp_mfr_names
WHERE mfr_code = p.mfrcode)
Looking for relevant Microsoft Windows Whitepapers? Visit the SearchEnterpriseDesktop.com Research Library.
Tudz Drkl | Oct 25 2007 1:09PM GMT
Your update query will work - this is a very common update method - only if the correlated subquery returns only one row for each mfr_code. Check your data by looking for multiple rows by GROUPING BY mfr_code. Also make sure you do not have any NULL mfr_codes. Another good practice is to always add an exists clause to a correlated update. This exist clause will include the same join criteria and predicates as the update subquery and ensure you do not update rows not intended for update:
AND EXISTS ( SELECT 1
FROM eqp_mfr_names
WHERE mfr_code = p.mfrcode)