Wednesday, April 1, 2009

SQL - Update table A from table B

-- SIMPLE UPDATE QUERY FROM TABLE A TO B
UPDATE TABLEA
SET TABLEA.[NAME] = TABLEB.[NAME]
FROM TABLEB
WHERE TABLEB.ID = TABLEA.ID

-- USING JOINS
UPDATE TABLEA
SET TABLEA.[NAME] = TABLEB.[NAME]
FROM TABLEB
INNER JOIN TABLEC
ON TABLEC.FIELD1 = TABLEB.FIELD1
WHERE TABLEB.ID = TABLEA.ID

No comments:

Post a Comment