In SQL Server, it is possible to make a INSERT INTO
to a table using a SELECT
:
INSERT INTO tabla (col, col2, col3)
SELECT col, col2, col3 FROM otra_tabla WHERE sql = 'ok'
Is this also possible for a UPDATE
? I have a temporary table that contains the values, and I would like to update another table using those values. Maybe something like:
UPDATE tabla SET col1, col2
SELECT col1, col2 FROM otra_tabla WHERE sql = 'ok'
WHERE tabla.id = otra_tabla.id