Sqlserver
 sql >> Datenbank >  >> RDS >> Sqlserver

SQL-Aktualisierungsabfragesyntax mit Inner Join

Das SET muss vor dem FROM\JOIN\WHERE stehen Teil der Abfrage.

UPDATE CE
SET sJobNumber = AD.JobNumber
FROM CostEntry CE 
    INNER JOIN ActiveCostDetails As AD 
        ON CE.lUniqueID = AD.UniqueID
WHERE CE.SEmployeeCode = '002'
    AND SubString(CostCentre, 1, 1) = sDepartmentCode
    AND substring(CostCentre, 3, 1) = sCategoryCode
    AND substring(CostCentre, 5, 2) = sOperationCode