How to insert to multiple table, how to update one tables from it multiple tables and how to delete it multiple on currently?
A:
The only way to INSERT
to multiple tables is to write multiple INSERT
statements. Same goes for DELETE
. They are single-table operations.
You can UPDATE
one table using several other source tables with a simple JOIN
like so:
UPDATE t1
SET t1.Name = t3.Name
FROM Table1 t1
INNER JOIN Table2 t2
ON t2.ID = t1.ID
INNER JOIN Table3 t3
ON t3.OtherID = t2.OtherID
Aaronaught
2010-02-05 04:41:32